STORM-2113 - uri parsing cleanup and fixes
parent
5c6cf3e7fb
commit
5a282abe18
|
|
@ -327,6 +327,7 @@ Cinder Roxley
|
|||
STORM-2036
|
||||
STORM-2037
|
||||
STORM-2053
|
||||
STORM-2113
|
||||
Clara Young
|
||||
Coaldust Numbers
|
||||
VWR-1095
|
||||
|
|
@ -1231,6 +1232,7 @@ Sovereign Engineer
|
|||
MAINT-2334
|
||||
OPEN-189
|
||||
STORM-1972
|
||||
STORM-2113
|
||||
OPEN-195
|
||||
OPEN-217
|
||||
OPEN-295
|
||||
|
|
|
|||
|
|
@ -118,11 +118,14 @@ void LLUriParser::fragment(const std::string& s)
|
|||
|
||||
void LLUriParser::textRangeToString(UriTextRangeA& textRange, std::string& str)
|
||||
{
|
||||
S32 len = textRange.afterLast - textRange.first;
|
||||
if (len)
|
||||
if (textRange.first != NULL && textRange.afterLast != NULL && textRange.first < textRange.afterLast)
|
||||
{
|
||||
str = textRange.first;
|
||||
str = str.substr(0, len);
|
||||
const ptrdiff_t len = textRange.afterLast - textRange.first;
|
||||
str.assign(textRange.first, static_cast<std::string::size_type>(len));
|
||||
}
|
||||
else
|
||||
{
|
||||
str = LLStringUtil::null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class LL_COMMON_API LLUriParser
|
|||
{
|
||||
public:
|
||||
LLUriParser(const std::string& u);
|
||||
virtual ~LLUriParser();
|
||||
~LLUriParser();
|
||||
|
||||
const char * scheme() const;
|
||||
void sheme (const std::string& s);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@
|
|||
#include "lltextutil.h"
|
||||
#include "lltooltip.h"
|
||||
#include "lluictrl.h"
|
||||
#include "lluriparser.h"
|
||||
#include "llurlaction.h"
|
||||
#include "llurlregistry.h"
|
||||
#include "llview.h"
|
||||
|
|
|
|||
|
|
@ -39,8 +39,6 @@
|
|||
#include "lluicolortable.h"
|
||||
#include "message.h"
|
||||
|
||||
#include "uriparser/Uri.h"
|
||||
|
||||
#define APP_HEADER_REGEX "((x-grid-location-info://[-\\w\\.]+/app)|(secondlife:///app))"
|
||||
|
||||
// Utility functions
|
||||
|
|
@ -347,27 +345,36 @@ std::string LLUrlEntrySLURL::getLocation(const std::string &url) const
|
|||
//
|
||||
// LLUrlEntrySeconlifeURLs Describes *secondlife.com and *lindenlab.com urls to substitute icon 'hand.png' before link
|
||||
//
|
||||
LLUrlEntrySeconlifeURL::LLUrlEntrySeconlifeURL()
|
||||
LLUrlEntrySecondlifeURL::LLUrlEntrySecondlifeURL()
|
||||
{
|
||||
mPattern = boost::regex("\\b(https?://)?([-\\w\\.]*\\.)?(secondlife|lindenlab)\\.com(:\\d{1,5})?(/\\S*)?\\b",
|
||||
boost::regex::perl|boost::regex::icase);
|
||||
|
||||
mIcon = "Hand";
|
||||
mMenuName = "menu_url_http.xml";
|
||||
mTooltip = LLTrans::getString("TooltipHttpUrl");
|
||||
}
|
||||
|
||||
std::string LLUrlEntrySeconlifeURL::getLabel(const std::string &url, const LLUrlLabelCallback &cb)
|
||||
/// Return the url from a string that matched the regex
|
||||
std::string LLUrlEntrySecondlifeURL::getUrl(const std::string &string) const
|
||||
{
|
||||
LLUriParser up(url);
|
||||
up.extractParts();
|
||||
return up.host();
|
||||
if (string.find("://") == std::string::npos)
|
||||
{
|
||||
return "https://" + escapeUrl(string);
|
||||
}
|
||||
return escapeUrl(string);
|
||||
}
|
||||
|
||||
std::string LLUrlEntrySeconlifeURL::getTooltip(const std::string &url) const
|
||||
std::string LLUrlEntrySecondlifeURL::getLabel(const std::string &url, const LLUrlLabelCallback &cb)
|
||||
{
|
||||
return url;
|
||||
}
|
||||
|
||||
std::string LLUrlEntrySecondlifeURL::getTooltip(const std::string &url) const
|
||||
{
|
||||
return mTooltip;
|
||||
}
|
||||
|
||||
//
|
||||
// LLUrlEntryAgent Describes a Second Life agent Url, e.g.,
|
||||
// secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about
|
||||
|
|
|
|||
|
|
@ -172,11 +172,12 @@ public:
|
|||
///
|
||||
/// LLUrlEntrySeconlifeURLs Describes *secondlife.com and *lindenlab.com Urls
|
||||
///
|
||||
class LLUrlEntrySeconlifeURL : public LLUrlEntryBase
|
||||
class LLUrlEntrySecondlifeURL : public LLUrlEntryBase
|
||||
{
|
||||
public:
|
||||
LLUrlEntrySeconlifeURL();
|
||||
bool isTrusted() const { return true; }
|
||||
LLUrlEntrySecondlifeURL();
|
||||
/*virtual*/ bool isTrusted() const { return true; }
|
||||
/*virtual*/ std::string getUrl(const std::string &string) const;
|
||||
/*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb);
|
||||
/*virtual*/ std::string getTooltip(const std::string &url) const;
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ LLUrlRegistry::LLUrlRegistry()
|
|||
registerUrl(new LLUrlEntrySLURL());
|
||||
|
||||
// decorated links for host names like: secondlife.com and lindenlab.com
|
||||
registerUrl(new LLUrlEntrySeconlifeURL());
|
||||
registerUrl(new LLUrlEntrySecondlifeURL());
|
||||
|
||||
registerUrl(new LLUrlEntryHTTP());
|
||||
mUrlEntryHTTPLabel = new LLUrlEntryHTTPLabel();
|
||||
|
|
@ -209,9 +209,12 @@ bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LL
|
|||
// fill in the LLUrlMatch object and return it
|
||||
std::string url = text.substr(match_start, match_end - match_start + 1);
|
||||
|
||||
LLUriParser up(url);
|
||||
up.normalize();
|
||||
url = up.normalizedUri();
|
||||
if (match_entry == mUrlEntryTrusted)
|
||||
{
|
||||
LLUriParser up(url);
|
||||
up.normalize();
|
||||
url = up.normalizedUri();
|
||||
}
|
||||
|
||||
match.setValues(match_start, match_end,
|
||||
match_entry->getUrl(url),
|
||||
|
|
@ -243,7 +246,7 @@ bool LLUrlRegistry::findUrl(const LLWString &text, LLUrlMatch &match, const LLUr
|
|||
// character encoding, so we need to update the start
|
||||
// and end values to be correct for the wide string.
|
||||
LLWString wurl = utf8str_to_wstring(match.getUrl());
|
||||
S32 start = text.find(wurl);
|
||||
size_t start = text.find(wurl);
|
||||
if (start == std::string::npos)
|
||||
{
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ private:
|
|||
friend class LLSingleton<LLUrlRegistry>;
|
||||
|
||||
std::vector<LLUrlEntryBase *> mUrlEntry;
|
||||
LLUrlEntryBase* mUrlEntryTrusted;
|
||||
LLUrlEntryBase* mUrlEntryIcon;
|
||||
LLUrlEntryBase* mUrlEntryHTTPLabel;
|
||||
LLUrlEntryBase* mUrlEntrySLLabel;
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
#include "llviewerregion.h"
|
||||
#include "llviewerwindow.h"
|
||||
#include "llnotificationsutil.h"
|
||||
|
||||
#include "lluriparser.h"
|
||||
#include "uriparser/Uri.h"
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
|
|
@ -240,19 +240,10 @@ bool LLWeb::useExternalBrowser(const std::string &url)
|
|||
}
|
||||
else if (gSavedSettings.getU32("PreferredBrowserBehavior") == BROWSER_INT_LL_EXT_OTHERS)
|
||||
{
|
||||
UriParserStateA state;
|
||||
UriUriA uri;
|
||||
state.uri = &uri;
|
||||
|
||||
std::string uri_string = url;
|
||||
uriParseUriA(&state, uri_string.c_str());
|
||||
if (uri.hostText.first)
|
||||
{
|
||||
S32 length = uri.hostText.afterLast - uri.hostText.first;
|
||||
std::string buf = uri.hostText.first;
|
||||
uri_string = buf.substr(0,length);
|
||||
}
|
||||
uriFreeUriMembersA(&uri);
|
||||
LLUriParser up(url);
|
||||
up.normalize();
|
||||
up.extractParts();
|
||||
std::string uri_string = up.host();
|
||||
|
||||
boost::regex pattern = boost::regex("\\b(lindenlab.com|secondlife.com)$", boost::regex::perl|boost::regex::icase);
|
||||
boost::match_results<std::string::const_iterator> matches;
|
||||
|
|
|
|||
Loading…
Reference in New Issue