summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
authormaksymsproductengine <maksymsproductengine@lindenlab.com>2014-09-22 20:01:55 +0300
committermaksymsproductengine <maksymsproductengine@lindenlab.com>2014-09-22 20:01:55 +0300
commit61e05f912557e3086cd80a10075aeaa6586519be (patch)
tree273d774f45d2522041c752015dc4247890dfc7e3 /indra/llui
parent9c4a8951fffb2a649647178f396f01cf68f114fc (diff)
MAINT-4170 Eliminate homoglyphs in URL hostnames: used 3p-uriparser;
Diffstat (limited to 'indra/llui')
-rwxr-xr-xindra/llui/CMakeLists.txt3
-rwxr-xr-xindra/llui/lltextbase.cpp43
-rwxr-xr-xindra/llui/lltextbase.h1
3 files changed, 46 insertions, 1 deletions
diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt
index 52738aeb6f..24fdc2268d 100755
--- a/indra/llui/CMakeLists.txt
+++ b/indra/llui/CMakeLists.txt
@@ -12,6 +12,7 @@ include(LLRender)
include(LLWindow)
include(LLVFS)
include(LLXML)
+include(URIPARSER)
include_directories(
${LLCOMMON_INCLUDE_DIRS}
@@ -28,6 +29,7 @@ include_directories(
include_directories(SYSTEM
${LLCOMMON_SYSTEM_INCLUDE_DIRS}
${LLXML_SYSTEM_INCLUDE_DIRS}
+ ${URIPARSER_INCLUDE_DIRS}
)
set(llui_SOURCE_FILES
@@ -278,6 +280,7 @@ target_link_libraries(llui
${LLXML_LIBRARIES}
${LLMATH_LIBRARIES}
${HUNSPELL_LIBRARY}
+ ${URIPARSER_LIBRARIES}
${LLCOMMON_LIBRARIES} # must be after llimage, llwindow, llrender
)
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index 9b125a85b9..b9c3417dc8 100755
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -44,6 +44,8 @@
#include "llwindow.h"
#include <boost/bind.hpp>
+#include "uriparser/Uri.h"
+
const F32 CURSOR_FLASH_DELAY = 1.0f; // in seconds
const S32 CURSOR_THICKNESS = 2;
const F32 TRIPLE_CLICK_INTERVAL = 0.3f; // delay between double and triple click.
@@ -2019,6 +2021,41 @@ static LLUIImagePtr image_from_icon_name(const std::string& icon_name)
static LLTrace::BlockTimerStatHandle FTM_PARSE_HTML("Parse HTML");
+S32 LLTextBase::normalizeUri(std::string& uri_string)
+{
+ UriParserStateA state;
+ UriUriA uri;
+ state.uri = &uri;
+
+ S32 res = uriParseUriA(&state, uri_string.c_str());
+
+ if (!res)
+ {
+ res = uriNormalizeSyntaxExA(&uri, URI_NORMALIZE_SCHEME | URI_NORMALIZE_HOST);
+
+ if (!res)
+ {
+ S32 chars_required;
+ res = uriToStringCharsRequiredA(&uri, &chars_required);
+
+ if (!res)
+ {
+ chars_required++;
+ std::vector<char> label_buf(chars_required);
+ res = uriToStringA(&label_buf[0], &uri, chars_required, NULL);
+
+ if (!res)
+ {
+ uri_string = &label_buf[0];
+ }
+ }
+ }
+ }
+
+ uriFreeUriMembersA(&uri);
+ return res;
+}
+
void LLTextBase::appendTextImpl(const std::string &new_text, const LLStyle::Params& input_params)
{
LLStyle::Params style_params(input_params);
@@ -2055,8 +2092,12 @@ void LLTextBase::appendTextImpl(const std::string &new_text, const LLStyle::Para
std::string subtext=text.substr(0,start);
appendAndHighlightText(subtext, part, style_params);
}
+
+ std::string label = match.getLabel();
+ normalizeUri(label);
+
// output the styled Url
- appendAndHighlightTextImpl(match.getLabel(), part, link_params, match.underlineOnHoverOnly());
+ appendAndHighlightTextImpl(label, part, link_params, match.underlineOnHoverOnly());
// set the tooltip for the Url label
if (! match.getTooltip().empty())
diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h
index 738b4d5b8e..dfc10923f3 100755
--- a/indra/llui/lltextbase.h
+++ b/indra/llui/lltextbase.h
@@ -590,6 +590,7 @@ protected:
void appendTextImpl(const std::string &new_text, const LLStyle::Params& input_params = LLStyle::Params());
void appendAndHighlightTextImpl(const std::string &new_text, S32 highlight_part, const LLStyle::Params& style_params, bool underline_on_hover_only = false);
+ S32 normalizeUri(std::string& uri);
protected: