summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dyukov <adyukov@productengine.com>2010-02-22 19:22:43 +0200
committerAndrew Dyukov <adyukov@productengine.com>2010-02-22 19:22:43 +0200
commit16b284971ebb6ecb41ba65d5fd9da87bc08bcba3 (patch)
tree8f878d54bb806b4783d24d87f9a456b0cb03bc6c
parenta7d716c35e57881a016c69752fa5f46dfd314ad9 (diff)
Fixed normal bug EXT-4964 (Invalid SLURL detection does not detect invalid slurls).
- Added new static method LLSLURL::isValidSLURL() whic uses LLUrlRegistry::isUrl() to validate SLURLs and not just chek prefixes as LLSLURL::isSLURL() does. - Used it in slurl DnD check in LLViewerWindow. - LLUrlEntrySLURL regexp was changed not to pass non-valid SLURLS (such as one from the bug description). --HG-- branch : product-engine
-rw-r--r--indra/llui/llurlentry.cpp2
-rw-r--r--indra/newview/llslurl.cpp16
-rw-r--r--indra/newview/llslurl.h5
-rw-r--r--indra/newview/llviewerwindow.cpp2
4 files changed, 24 insertions, 1 deletions
diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp
index 3c73ae9b0c..20c939874b 100644
--- a/indra/llui/llurlentry.cpp
+++ b/indra/llui/llurlentry.cpp
@@ -232,7 +232,7 @@ std::string LLUrlEntryHTTPNoProtocol::getUrl(const std::string &string) const
LLUrlEntrySLURL::LLUrlEntrySLURL()
{
// see http://slurl.com/about.php for details on the SLURL format
- mPattern = boost::regex("http://(maps.secondlife.com|slurl.com)/secondlife/\\S+/?(\\d+)?/?(\\d+)?/?(\\d+)?/?\\S*",
+ mPattern = boost::regex("http://(maps.secondlife.com|slurl.com)/secondlife/[^ /]+(/\\d+){0,3}(/?(\\?title|\\?img|\\?msg)=\\S*)?/?",
boost::regex::perl|boost::regex::icase);
mMenuName = "menu_url_slurl.xml";
mTooltip = LLTrans::getString("TooltipSLURL");
diff --git a/indra/newview/llslurl.cpp b/indra/newview/llslurl.cpp
index e4773f99c5..5d20e280b5 100644
--- a/indra/newview/llslurl.cpp
+++ b/indra/newview/llslurl.cpp
@@ -36,6 +36,8 @@
#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://";
@@ -95,6 +97,20 @@ bool LLSLURL::isSLURL(const std::string& url)
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)
{
diff --git a/indra/newview/llslurl.h b/indra/newview/llslurl.h
index 6a695e84f3..a79a8fc97c 100644
--- a/indra/newview/llslurl.h
+++ b/indra/newview/llslurl.h
@@ -61,6 +61,11 @@ public:
static bool isSLURL(const std::string& url);
/**
+ * Returns true if url is proven valid by regexp check from LLUrlRegistry
+ */
+ static bool isValidSLURL(const std::string& url);
+
+ /**
* Is this a special secondlife://app/ URL?
*/
static bool isSLURLCommand(const std::string& url);
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 1acf114b12..591b1de509 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -826,6 +826,8 @@ LLWindowCallbacks::DragNDropResult LLViewerWindow::handleDragNDrop( LLWindow *wi
if (slurl_dnd_enabled)
{
+ // isValidSLURL() call was added here to make sure that dragged SLURL is valid (EXT-4964)
+ if ( LLSLURL::isSLURL( data ) && LLSLURL::isValidSLURL( data ) )
// special case SLURLs
if ( LLSLURL::isSLURL( data ) )
{