diff options
author | Lynx Linden <lynx@lindenlab.com> | 2010-01-29 14:30:26 +0000 |
---|---|---|
committer | Lynx Linden <lynx@lindenlab.com> | 2010-01-29 14:30:26 +0000 |
commit | 4d6c9e3e1754d21ea5291207085113e99456f571 (patch) | |
tree | 3a74789a0d5573863bc2e40ab6b364e589bb8697 /indra/llui/llurlentry.cpp | |
parent | ec5dbb60e71302a77f68cc604e7dfd52bcaa926a (diff) |
EXT-4678: Support <nolink>...</nolink> to turn off URL hyperlinking.
We are running into a bunch of places where we don't want to allow
hyperlinking of URLs like secondlife.com in text boxes. I've therefore
added a new type of URL regex that disables URL hyperlinking. Simply
enclose the URL in a <nolink> tag, e.g.:
<nolink>secondlife.com</nolink>
Diffstat (limited to 'indra/llui/llurlentry.cpp')
-rw-r--r-- | indra/llui/llurlentry.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp index 4927e57a52..58148ad2aa 100644 --- a/indra/llui/llurlentry.cpp +++ b/indra/llui/llurlentry.cpp @@ -39,8 +39,9 @@ #include "lltrans.h" #include "lluicolortable.h" -LLUrlEntryBase::LLUrlEntryBase() -: mColor(LLUIColorTable::instance().getColor("HTMLLinkColor")) +LLUrlEntryBase::LLUrlEntryBase() : + mColor(LLUIColorTable::instance().getColor("HTMLLinkColor")), + mDisabledLink(false) { } @@ -204,7 +205,7 @@ LLUrlEntryHTTPNoProtocol::LLUrlEntryHTTPNoProtocol() mPattern = boost::regex("(" "\\bwww\\.\\S+\\.\\S+" // i.e. www.FOO.BAR "|" // or - "(?<!@)\\b[^[:space:]:@/]+\\.(?:com|net|edu|org)([/:]\\S*)?\\b" // i.e. FOO.net + "(?<!@)\\b[^[:space:]:@/>]+\\.(?:com|net|edu|org)([/:][^[:space:]<]*)?\\b" // i.e. FOO.net ")", boost::regex::perl|boost::regex::icase); mMenuName = "menu_url_http.xml"; @@ -641,3 +642,20 @@ std::string LLUrlEntryWorldMap::getLocation(const std::string &url) const // return the part of the Url after secondlife:///app/worldmap/ part return ::getStringAfterToken(url, "app/worldmap/"); } + +// +// LLUrlEntryNoLink lets us turn of URL detection with <nolink>...</nolink> tags +// +LLUrlEntryNoLink::LLUrlEntryNoLink() +{ + mPattern = boost::regex("<nolink>[^[:space:]<]+</nolink>", + boost::regex::perl|boost::regex::icase); + mDisabledLink = true; +} + +std::string LLUrlEntryNoLink::getLabel(const std::string &url, const LLUrlLabelCallback &cb) +{ + // return the text between the <nolink> and </nolink> tags + return url.substr(8, url.size()-8-9); +} + |