diff options
Diffstat (limited to 'indra/newview/llslurl.cpp')
-rw-r--r-- | indra/newview/llslurl.cpp | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/indra/newview/llslurl.cpp b/indra/newview/llslurl.cpp index 37e268ad34..5d20e280b5 100644 --- a/indra/newview/llslurl.cpp +++ b/indra/newview/llslurl.cpp @@ -36,10 +36,19 @@ #include "llweb.h" +#include "llurlregistry.h" + const std::string LLSLURL::PREFIX_SL_HELP = "secondlife://app."; const std::string LLSLURL::PREFIX_SL = "sl://"; const std::string LLSLURL::PREFIX_SECONDLIFE = "secondlife://"; -const std::string LLSLURL::PREFIX_SLURL = "http://slurl.com/secondlife/"; +const std::string LLSLURL::PREFIX_SLURL_OLD = "http://slurl.com/secondlife/"; + +// For DnD - even though www.slurl.com redirects to slurl.com in a browser, you can copy and drag +// text with www.slurl.com or a link explicitly pointing at www.slurl.com so testing for this +// version is required also. +const std::string LLSLURL::PREFIX_SLURL_WWW = "http://www.slurl.com/secondlife/"; + +const std::string LLSLURL::PREFIX_SLURL = "http://maps.secondlife.com/secondlife/"; const std::string LLSLURL::APP_TOKEN = "app/"; @@ -63,6 +72,14 @@ std::string LLSLURL::stripProtocol(const std::string& url) { stripped.erase(0, PREFIX_SLURL.length()); } + else if (matchPrefix(stripped, PREFIX_SLURL_OLD)) + { + stripped.erase(0, PREFIX_SLURL_OLD.length()); + } + else if (matchPrefix(stripped, PREFIX_SLURL_WWW)) + { + stripped.erase(0, PREFIX_SLURL_WWW.length()); + } return stripped; } @@ -74,16 +91,34 @@ bool LLSLURL::isSLURL(const std::string& url) if (matchPrefix(url, PREFIX_SL)) return true; if (matchPrefix(url, PREFIX_SECONDLIFE)) return true; if (matchPrefix(url, PREFIX_SLURL)) return true; + if (matchPrefix(url, PREFIX_SLURL_OLD)) return true; + if (matchPrefix(url, PREFIX_SLURL_WWW)) return true; return false; } +bool LLSLURL::isValidSLURL(const std::string& url) +{ + std::string temp_url(url); + //"www." may appear in DnD- see description of PREFIX_SLURL_WWW. + // If it is found, we remove it because it isn't expected in regexp. + if (matchPrefix(url, PREFIX_SLURL_WWW)) + { + size_t position = url.find("www."); + temp_url.erase(position,4); + } + + return LLUrlRegistry::getInstance()->isUrl(temp_url); +} + // static bool LLSLURL::isSLURLCommand(const std::string& url) { if (matchPrefix(url, PREFIX_SL + APP_TOKEN) || matchPrefix(url, PREFIX_SECONDLIFE + "/" + APP_TOKEN) || - matchPrefix(url, PREFIX_SLURL + APP_TOKEN) ) + matchPrefix(url, PREFIX_SLURL + APP_TOKEN) || + matchPrefix(url, PREFIX_SLURL_WWW + APP_TOKEN) || + matchPrefix(url, PREFIX_SLURL_OLD + APP_TOKEN) ) { return true; } |