From 61e05f912557e3086cd80a10075aeaa6586519be Mon Sep 17 00:00:00 2001 From: maksymsproductengine Date: Mon, 22 Sep 2014 20:01:55 +0300 Subject: MAINT-4170 Eliminate homoglyphs in URL hostnames: used 3p-uriparser; --- indra/llui/lltextbase.cpp | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'indra/llui/lltextbase.cpp') 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 +#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 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()) -- cgit v1.2.3 From dd8d2b59f74ff01bd0b79b841e3974b3b00ddeb1 Mon Sep 17 00:00:00 2001 From: maksymsproductengine Date: Wed, 24 Sep 2014 23:09:30 +0300 Subject: MAINT-4170 FIXED Eliminate homoglyphs in URL hostnames: converting to lowercase links without scheme --- indra/llui/lltextbase.cpp | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) (limited to 'indra/llui/lltextbase.cpp') diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index b9c3417dc8..8395e74715 100755 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -2031,25 +2031,45 @@ S32 LLTextBase::normalizeUri(std::string& uri_string) if (!res) { - res = uriNormalizeSyntaxExA(&uri, URI_NORMALIZE_SCHEME | URI_NORMALIZE_HOST); - - if (!res) + if (uri.scheme.afterLast - uri.scheme.first > 0) { - S32 chars_required; - res = uriToStringCharsRequiredA(&uri, &chars_required); + res = uriNormalizeSyntaxExA(&uri, URI_NORMALIZE_SCHEME | URI_NORMALIZE_HOST); if (!res) { - chars_required++; - std::vector label_buf(chars_required); - res = uriToStringA(&label_buf[0], &uri, chars_required, NULL); + S32 chars_required; + res = uriToStringCharsRequiredA(&uri, &chars_required); if (!res) { - uri_string = &label_buf[0]; + chars_required++; + std::vector label_buf(chars_required); + res = uriToStringA(&label_buf[0], &uri, chars_required, NULL); + + if (!res) + { + uri_string = &label_buf[0]; + } } } } + else if (uri_string.find_first_of('.') != std::string::npos) + { + static bool recursive_call = false; + + // allow only single level recursive call + if (!recursive_call) + { + recursive_call = true; + + // force uri to be with scheme and try to normalize + std::string uri_with_scheme = "http://"; + uri_with_scheme += uri_string; + normalizeUri(uri_with_scheme); + uri_string = uri_with_scheme.substr(7); + recursive_call = false; + } + } } uriFreeUriMembersA(&uri); -- cgit v1.2.3 From a25748e11ea59d72f8190373be5b8930288d4744 Mon Sep 17 00:00:00 2001 From: maksymsproductengine Date: Thu, 2 Oct 2014 18:20:10 +0300 Subject: MAINT-4119 FIXED Uniquely decorate links on Second Life or Linden Lab domains --- indra/llui/lltextbase.cpp | 70 ++++++----------------------------------------- 1 file changed, 8 insertions(+), 62 deletions(-) (limited to 'indra/llui/lltextbase.cpp') diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 8395e74715..fee271b943 100755 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -44,8 +44,6 @@ #include "llwindow.h" #include -#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. @@ -2021,60 +2019,7 @@ 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) - { - if (uri.scheme.afterLast - uri.scheme.first > 0) - { - 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 label_buf(chars_required); - res = uriToStringA(&label_buf[0], &uri, chars_required, NULL); - - if (!res) - { - uri_string = &label_buf[0]; - } - } - } - } - else if (uri_string.find_first_of('.') != std::string::npos) - { - static bool recursive_call = false; - - // allow only single level recursive call - if (!recursive_call) - { - recursive_call = true; - - // force uri to be with scheme and try to normalize - std::string uri_with_scheme = "http://"; - uri_with_scheme += uri_string; - normalizeUri(uri_with_scheme); - uri_string = uri_with_scheme.substr(7); - recursive_call = false; - } - } - } - - uriFreeUriMembersA(&uri); - return res; -} void LLTextBase::appendTextImpl(const std::string &new_text, const LLStyle::Params& input_params) { @@ -2113,8 +2058,11 @@ void LLTextBase::appendTextImpl(const std::string &new_text, const LLStyle::Para appendAndHighlightText(subtext, part, style_params); } + // add icon before url if need + LLTextUtil::processUrlMatch(&match, this, isContentTrusted() || match.isTrusted()); + std::string label = match.getLabel(); - normalizeUri(label); + LLTextUtil::normalizeUri(label); // output the styled Url appendAndHighlightTextImpl(label, part, link_params, match.underlineOnHoverOnly()); @@ -2124,14 +2072,12 @@ void LLTextBase::appendTextImpl(const std::string &new_text, const LLStyle::Para { segment_set_t::iterator it = getSegIterContaining(getLength()-1); if (it != mSegments.end()) - { - LLTextSegmentPtr segment = *it; - segment->setToolTip(match.getTooltip()); - } + { + LLTextSegmentPtr segment = *it; + segment->setToolTip(match.getTooltip()); + } } - LLTextUtil::processUrlMatch(&match,this,isContentTrusted()); - // move on to the rest of the text after the Url if (end < (S32)text.length()) { -- cgit v1.2.3 From 6ea75fd4b03ce3a9155781764c9bcf13a637b749 Mon Sep 17 00:00:00 2001 From: maksymsproductengine Date: Tue, 7 Oct 2014 18:59:11 +0300 Subject: MAINT-4548 & MAINT-4557 FIXED build issues --- indra/llui/lltextbase.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'indra/llui/lltextbase.cpp') diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index fee271b943..09f923e74f 100755 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -38,6 +38,7 @@ #include "lltextutil.h" #include "lltooltip.h" #include "lluictrl.h" +#include "lluriparser.h" #include "llurlaction.h" #include "llurlregistry.h" #include "llview.h" @@ -2061,11 +2062,9 @@ void LLTextBase::appendTextImpl(const std::string &new_text, const LLStyle::Para // add icon before url if need LLTextUtil::processUrlMatch(&match, this, isContentTrusted() || match.isTrusted()); - std::string label = match.getLabel(); - LLTextUtil::normalizeUri(label); - // output the styled Url - appendAndHighlightTextImpl(label, part, link_params, match.underlineOnHoverOnly()); + //appendAndHighlightTextImpl(label, part, link_params, match.underlineOnHoverOnly()); + appendAndHighlightTextImpl(match.getLabel(), part, link_params, match.underlineOnHoverOnly()); // set the tooltip for the Url label if (! match.getTooltip().empty()) -- cgit v1.2.3