MAINT-4683 FIXED Display SLURLs with incorrect coordinates as regular URLs.
parent
4734125659
commit
28e8b8ecdb
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
///
|
||||
|
|
|
|||
|
|
@ -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)))
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ private:
|
|||
|
||||
std::vector<LLUrlEntryBase *> mUrlEntry;
|
||||
LLUrlEntryBase* mUrlEntryIcon;
|
||||
LLUrlEntryBase* mLLUrlEntryInvalidSLURL;
|
||||
LLUrlEntryBase* mUrlEntryHTTPLabel;
|
||||
LLUrlEntryBase* mUrlEntrySLLabel;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue