summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorMnikolenko ProductEngine <mnikolenko@productengine.com>2014-12-04 12:40:13 +0200
committerMnikolenko ProductEngine <mnikolenko@productengine.com>2014-12-04 12:40:13 +0200
commit28e8b8ecdbf7a5aecf9e0dec2e673e832baf642f (patch)
tree408b69e9e900443923af196708d04cb082119d1f /indra
parent4734125659ca7fa5d5f86c306a929a4a12cc80ae (diff)
MAINT-4683 FIXED Display SLURLs with incorrect coordinates as regular URLs.
Diffstat (limited to 'indra')
-rwxr-xr-xindra/llui/llurlentry.cpp85
-rwxr-xr-xindra/llui/llurlentry.h13
-rwxr-xr-xindra/llui/llurlregistry.cpp10
-rwxr-xr-xindra/llui/llurlregistry.h1
4 files changed, 109 insertions, 0 deletions
diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp
index ac023e664d..adf010cd5d 100755
--- a/indra/llui/llurlentry.cpp
+++ b/indra/llui/llurlentry.cpp
@@ -332,6 +332,90 @@ std::string LLUrlEntryHTTPNoProtocol::getTooltip(const std::string &url) const
return unescapeUrl(url);
}
+LLUrlEntryInvalidSLURL::LLUrlEntryInvalidSLURL()
+ : LLUrlEntryBase()
+{
+ mPattern = boost::regex("(http://(maps.secondlife.com|slurl.com)/secondlife/|secondlife://(/app/(worldmap|teleport)/)?)[^ /]+(/-?[0-9]+){1,3}(/?(\\?title|\\?img|\\?msg)=\\S*)?/?",
+ boost::regex::perl|boost::regex::icase);
+ mMenuName = "menu_url_http.xml";
+ mTooltip = LLTrans::getString("TooltipHttpUrl");
+}
+
+std::string LLUrlEntryInvalidSLURL::getLabel(const std::string &url, const LLUrlLabelCallback &cb)
+{
+
+ return escapeUrl(url);
+}
+
+std::string LLUrlEntryInvalidSLURL::getUrl(const std::string &string) const
+{
+ return escapeUrl(string);
+}
+
+std::string LLUrlEntryInvalidSLURL::getTooltip(const std::string &url) const
+{
+ return unescapeUrl(url);
+}
+
+bool LLUrlEntryInvalidSLURL::isSLURLvalid(const std::string &url) const
+{
+ S32 actual_parts;
+
+ if(url.find(".com/secondlife/") != std::string::npos)
+ {
+ actual_parts = 5;
+ }
+ else if(url.find("/app/") != std::string::npos)
+ {
+ actual_parts = 6;
+ }
+ else
+ {
+ actual_parts = 3;
+ }
+
+ LLURI uri(url);
+ LLSD path_array = uri.pathArray();
+ S32 path_parts = path_array.size();
+ S32 x,y,z;
+
+ if (path_parts == actual_parts)
+ {
+ // handle slurl with (X,Y,Z) coordinates
+ LLStringUtil::convertToS32(path_array[path_parts-3],x);
+ LLStringUtil::convertToS32(path_array[path_parts-2],y);
+ LLStringUtil::convertToS32(path_array[path_parts-1],z);
+
+ if((x>= 0 && x<= 256) && (y>= 0 && y<= 256) && (z>= 0))
+ {
+ return TRUE;
+ }
+ }
+ else if (path_parts == (actual_parts-1))
+ {
+ // handle slurl with (X,Y) coordinates
+
+ LLStringUtil::convertToS32(path_array[path_parts-2],x);
+ LLStringUtil::convertToS32(path_array[path_parts-1],y);
+ ;
+ if((x>= 0 && x<= 256) && (y>= 0 && y<= 256))
+ {
+ return TRUE;
+ }
+ }
+ else if (path_parts == (actual_parts-2))
+ {
+ // handle slurl with (X) coordinate
+ LLStringUtil::convertToS32(path_array[path_parts-1],x);
+ if(x>= 0 && x<= 256)
+ {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
//
// LLUrlEntrySLURL Describes generic http: and https: Urls
//
@@ -353,6 +437,7 @@ std::string LLUrlEntrySLURL::getLabel(const std::string &url, const LLUrlLabelCa
// - http://slurl.com/secondlife/Place/X
// - http://slurl.com/secondlife/Place
//
+
LLURI uri(url);
LLSD path_array = uri.pathArray();
S32 path_parts = path_array.size();
diff --git a/indra/llui/llurlentry.h b/indra/llui/llurlentry.h
index fd18389303..1e82adcd94 100755
--- a/indra/llui/llurlentry.h
+++ b/indra/llui/llurlentry.h
@@ -107,6 +107,8 @@ public:
bool isWikiLinkCorrect(std::string url);
+ virtual bool isSLURLvalid(const std::string &url) const { return TRUE; };
+
protected:
std::string getIDStringFromUrl(const std::string &url) const;
std::string escapeUrl(const std::string &url) const;
@@ -169,6 +171,17 @@ public:
/*virtual*/ std::string getTooltip(const std::string &url) const;
};
+class LLUrlEntryInvalidSLURL : public LLUrlEntryBase
+{
+public:
+ LLUrlEntryInvalidSLURL();
+ /*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb);
+ /*virtual*/ std::string getUrl(const std::string &string) const;
+ /*virtual*/ std::string getTooltip(const std::string &url) const;
+
+ bool isSLURLvalid(const std::string &url) const;
+};
+
///
/// LLUrlEntrySLURL Describes http://slurl.com/... Urls
///
diff --git a/indra/llui/llurlregistry.cpp b/indra/llui/llurlregistry.cpp
index 5918d97be4..88d2c4639d 100755
--- a/indra/llui/llurlregistry.cpp
+++ b/indra/llui/llurlregistry.cpp
@@ -44,6 +44,8 @@ LLUrlRegistry::LLUrlRegistry()
registerUrl(new LLUrlEntryNoLink());
mUrlEntryIcon = new LLUrlEntryIcon();
registerUrl(mUrlEntryIcon);
+ mLLUrlEntryInvalidSLURL = new LLUrlEntryInvalidSLURL();
+ registerUrl(mLLUrlEntryInvalidSLURL);
registerUrl(new LLUrlEntrySLURL());
// decorated links for host names like: secondlife.com and lindenlab.com
@@ -189,6 +191,14 @@ bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LL
if (start < match_start || match_entry == NULL)
{
+ if((mLLUrlEntryInvalidSLURL == *it))
+ {
+ if(url_entry && url_entry->isSLURLvalid(text.substr(start, end - start + 1)))
+ {
+ continue;
+ }
+ }
+
if((mUrlEntryHTTPLabel == *it) || (mUrlEntrySLLabel == *it))
{
if(url_entry && !url_entry->isWikiLinkCorrect(text.substr(start, end - start + 1)))
diff --git a/indra/llui/llurlregistry.h b/indra/llui/llurlregistry.h
index 1cb403dfc9..d85fbcb012 100755
--- a/indra/llui/llurlregistry.h
+++ b/indra/llui/llurlregistry.h
@@ -94,6 +94,7 @@ private:
std::vector<LLUrlEntryBase *> mUrlEntry;
LLUrlEntryBase* mUrlEntryIcon;
+ LLUrlEntryBase* mLLUrlEntryInvalidSLURL;
LLUrlEntryBase* mUrlEntryHTTPLabel;
LLUrlEntryBase* mUrlEntrySLLabel;
};