summaryrefslogtreecommitdiff
path: root/indra/llui/llurlentry.cpp
diff options
context:
space:
mode:
authormaksymsproductengine <maksymsproductengine@lindenlab.com>2014-10-13 19:14:42 +0300
committermaksymsproductengine <maksymsproductengine@lindenlab.com>2014-10-13 19:14:42 +0300
commit2b8827a55f6a935bac8abb7513be1c00659f6ab1 (patch)
treedc793cf932fd2220c6911519ebe836f3258e66bd /indra/llui/llurlentry.cpp
parent94ac0064354594de8adbb99084029c8b4027b2f6 (diff)
MAINT-4169 FIXED Suppress initial display of the path portion of URLs from other users and scripts
Diffstat (limited to 'indra/llui/llurlentry.cpp')
-rwxr-xr-xindra/llui/llurlentry.cpp97
1 files changed, 87 insertions, 10 deletions
diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp
index cc7956078d..daed158fe9 100755
--- a/indra/llui/llurlentry.cpp
+++ b/indra/llui/llurlentry.cpp
@@ -43,12 +43,16 @@
#define APP_HEADER_REGEX "((x-grid-location-info://[-\\w\\.]+/app)|(secondlife:///app))"
+extern LLControlGroup gSavedSettings;
+
// Utility functions
std::string localize_slapp_label(const std::string& url, const std::string& full_name);
LLUrlEntryBase::LLUrlEntryBase()
-{}
+{
+ mGreyQuery = gSavedSettings.getBOOL("HTTPNoProtocolShowGreyQuery");
+}
LLUrlEntryBase::~LLUrlEntryBase()
{
@@ -187,6 +191,33 @@ bool LLUrlEntryBase::isWikiLinkCorrect(std::string url)
return (LLUrlRegistry::instance().hasUrl(label)) ? false : true;
}
+std::string LLUrlEntryBase::urlToLabelWithGreyQuery(const std::string &url) const
+{
+ LLUriParser up(unescapeUrl(url));
+ up.normalize();
+
+ std::string label;
+ up.extractParts();
+ up.glueFirst(label);
+
+ return label;
+}
+
+std::string LLUrlEntryBase::urlToGreyQuery(const std::string &url) const
+{
+ LLUriParser up(unescapeUrl(url));
+
+ std::string query;
+ if (mGreyQuery)
+ {
+ up.extractParts();
+ up.glueSecond(query);
+ }
+
+ return query;
+}
+
+
static std::string getStringAfterToken(const std::string str, const std::string token)
{
size_t pos = str.find(token);
@@ -203,6 +234,7 @@ static std::string getStringAfterToken(const std::string str, const std::string
// LLUrlEntryHTTP Describes generic http: and https: Urls
//
LLUrlEntryHTTP::LLUrlEntryHTTP()
+ : LLUrlEntryBase()
{
mPattern = boost::regex("https?://([-\\w\\.]+)+(:\\d+)?(:\\w+)?(@\\d+)?(@\\w+)?/?\\S*",
boost::regex::perl|boost::regex::icase);
@@ -212,6 +244,25 @@ LLUrlEntryHTTP::LLUrlEntryHTTP()
std::string LLUrlEntryHTTP::getLabel(const std::string &url, const LLUrlLabelCallback &cb)
{
+ return urlToLabelWithGreyQuery(url);
+}
+
+std::string LLUrlEntryHTTP::getQuery(const std::string &url) const
+{
+ return urlToGreyQuery(url);
+}
+
+std::string LLUrlEntryHTTP::getUrl(const std::string &string) const
+{
+ if (string.find("://") == std::string::npos)
+ {
+ return "http://" + escapeUrl(string);
+ }
+ return escapeUrl(string);
+}
+
+std::string LLUrlEntryHTTP::getTooltip(const std::string &url) const
+{
return unescapeUrl(url);
}
@@ -247,6 +298,7 @@ std::string LLUrlEntryHTTPLabel::getUrl(const std::string &string) const
// LLUrlEntryHTTPNoProtocol Describes generic Urls like www.google.com
//
LLUrlEntryHTTPNoProtocol::LLUrlEntryHTTPNoProtocol()
+ : LLUrlEntryBase()
{
mPattern = boost::regex("("
"\\bwww\\.\\S+\\.\\S+" // i.e. www.FOO.BAR
@@ -260,7 +312,12 @@ LLUrlEntryHTTPNoProtocol::LLUrlEntryHTTPNoProtocol()
std::string LLUrlEntryHTTPNoProtocol::getLabel(const std::string &url, const LLUrlLabelCallback &cb)
{
- return unescapeUrl(url);
+ return urlToLabelWithGreyQuery(url);
+}
+
+std::string LLUrlEntryHTTPNoProtocol::getQuery(const std::string &url) const
+{
+ return urlToGreyQuery(url);
}
std::string LLUrlEntryHTTPNoProtocol::getUrl(const std::string &string) const
@@ -272,6 +329,11 @@ std::string LLUrlEntryHTTPNoProtocol::getUrl(const std::string &string) const
return escapeUrl(string);
}
+std::string LLUrlEntryHTTPNoProtocol::getTooltip(const std::string &url) const
+{
+ return unescapeUrl(url);
+}
+
//
// LLUrlEntrySLURL Describes generic http: and https: Urls
//
@@ -345,30 +407,33 @@ std::string LLUrlEntrySLURL::getLocation(const std::string &url) const
}
//
-// LLUrlEntrySeconlifeURLs Describes *secondlife.com and *lindenlab.com urls to substitute icon 'hand.png' before link
+// LLUrlEntrySeconlifeURL Describes *secondlife.com/ and *lindenlab.com/ urls to substitute icon 'hand.png' before link
//
-LLUrlEntrySeconlifeURL::LLUrlEntrySeconlifeURL()
-{
- mPattern = boost::regex("\\b(https?://)?([-\\w\\.]*\\.)?(secondlife|lindenlab)\\.com(:\\d{1,5})?(/\\S*)?\\b",
+LLUrlEntrySecondlifeURL::LLUrlEntrySecondlifeURL()
+{
+ mPattern = boost::regex("(https?://)?([-\\w\\.]*\\.)?(secondlife|lindenlab)\\.com(:\\d{1,5})?\\/\\S*",
boost::regex::perl|boost::regex::icase);
mIcon = "Hand";
mMenuName = "menu_url_http.xml";
}
-std::string LLUrlEntrySeconlifeURL::getLabel(const std::string &url, const LLUrlLabelCallback &cb)
+std::string LLUrlEntrySecondlifeURL::getLabel(const std::string &url, const LLUrlLabelCallback &cb)
{
LLUriParser up(url);
up.extractParts();
- return up.host();
+
+ std::string label;
+ up.glueFirst(label);
+ return label;
}
-std::string LLUrlEntrySeconlifeURL::getTooltip(const std::string &url) const
+std::string LLUrlEntrySecondlifeURL::getTooltip(const std::string &url) const
{
return url;
}
-std::string LLUrlEntrySeconlifeURL::getUrl(const std::string &string) const
+std::string LLUrlEntrySecondlifeURL::getUrl(const std::string &string) const
{
if (string.find("://") == std::string::npos)
{
@@ -378,6 +443,18 @@ std::string LLUrlEntrySeconlifeURL::getUrl(const std::string &string) const
}
//
+// LLUrlEntrySimpleSecondlifeURL Describes *secondlife.com and *lindenlab.com urls to substitute icon 'hand.png' before link
+//
+LLUrlEntrySimpleSecondlifeURL::LLUrlEntrySimpleSecondlifeURL()
+ {
+ mPattern = boost::regex("(https?://)?([-\\w\\.]*\\.)?(secondlife|lindenlab)\\.com(?!\\S)",
+ boost::regex::perl|boost::regex::icase);
+
+ mIcon = "Hand";
+ mMenuName = "menu_url_http.xml";
+}
+
+//
// LLUrlEntryAgent Describes a Second Life agent Url, e.g.,
// secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about
// x-grid-location-info://lincoln.lindenlab.com/app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about