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
master
Andrew Dyukov 2010-02-22 19:22:43 +02:00
parent a7d716c35e
commit 16b284971e
4 changed files with 24 additions and 1 deletions

View File

@ -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");

View File

@ -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)
{

View File

@ -60,6 +60,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?
*/

View File

@ -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 ) )
{