From 71baa9cdf4d74a7ab1d194b4f823416f5f450c39 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Thu, 11 Sep 2014 18:50:26 +0300 Subject: MAINT-4440 FIXED Bad colors for spillover menu in viewer-lion --- indra/llui/llmenugl.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/llui') diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index d3ed4a1286..3e6002e546 100755 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -2369,7 +2369,9 @@ void LLMenuGL::createSpilloverBranch() branch_params.label = label; branch_params.branch = mSpilloverMenu; branch_params.font.style = "italic"; - + branch_params.highlight_bg_color=LLUIColorTable::instance().getColor("MenuItemHighlightBgColor"); + branch_params.highlight_fg_color=LLUIColorTable::instance().getColor("MenuItemHighlightFgColor"); + branch_params.enabled_color=LLUIColorTable::instance().getColor("MenuItemEnabledColor"); mSpilloverBranch = LLUICtrlFactory::create(branch_params); } -- cgit v1.3 From eebb94159e061ec90e8dc1387a0de8f7a0733217 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Mon, 15 Sep 2014 20:29:36 +0300 Subject: MAINT-4437 FIXED Spillover Branch shows when it should not --- indra/llui/llmenugl.cpp | 67 +++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 33 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index 3e6002e546..cb0b75ea48 100755 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -60,6 +60,7 @@ #include "v2math.h" #include #include +#include // static LLMenuHolderGL *LLMenuGL::sMenuContainer = NULL; @@ -2038,15 +2039,7 @@ void LLMenuGL::arrange( void ) // torn off menus are not constrained to the size of the screen U32 max_width = getTornOff() ? U32_MAX : menu_region_rect.getWidth(); - U32 max_height = U32_MAX; - if (!getTornOff()) - { - max_height = getRect().mTop - menu_region_rect.mBottom; - if (menu_region_rect.mTop - getRect().mTop > (S32)max_height) - { - max_height = menu_region_rect.mTop - getRect().mTop; - } - } + U32 max_height = getTornOff() ? U32_MAX: menu_region_rect.getHeight(); // *FIX: create the item first and then ask for its dimensions? S32 spillover_item_width = PLAIN_PAD_PIXELS + LLFontGL::getFontSansSerif()->getWidth( std::string("More") ); // *TODO: Translate @@ -2104,13 +2097,15 @@ void LLMenuGL::arrange( void ) } else { + BOOST_FOREACH(LLMenuItemGL* itemp, mItems) + { + // do first so LLMenuGLItemCall can call on_visible to determine if visible + itemp->buildDrawLabel(); + } item_list_t::iterator item_iter; for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter) { - // do first so LLMenuGLItemCall can call on_visible to determine if visible - (*item_iter)->buildDrawLabel(); - if ((*item_iter)->getVisible()) { if (!getTornOff() @@ -2118,34 +2113,40 @@ void LLMenuGL::arrange( void ) && *item_iter != mSpilloverBranch && height + (*item_iter)->getNominalHeight() > max_height - spillover_item_height) { - // no room for any more items - createSpilloverBranch(); - - std::vector items_to_remove; - std::copy(item_iter, mItems.end(), std::back_inserter(items_to_remove)); - std::vector::iterator spillover_iter; - for (spillover_iter= items_to_remove.begin(); spillover_iter != items_to_remove.end(); ++spillover_iter) + // don't show only one item + int visible_items = std::count_if(item_iter, mItems.end(), [](LLMenuItemGL* itemp) { - LLMenuItemGL* itemp = (*spillover_iter); - removeChild(itemp); - mSpilloverMenu->addChild(itemp); - } + return itemp->getVisible(); + }); + if (visible_items>1) + { + // no room for any more items + createSpilloverBranch(); + std::vector items_to_remove; + std::copy(item_iter, mItems.end(), std::back_inserter(items_to_remove)); + std::vector::iterator spillover_iter; + for (spillover_iter= items_to_remove.begin(); spillover_iter != items_to_remove.end(); ++spillover_iter) + { + LLMenuItemGL* itemp = (*spillover_iter); + removeChild(itemp); + mSpilloverMenu->addChild(itemp); + } - addChild(mSpilloverBranch); - height += mSpilloverBranch->getNominalHeight(); - width = llmax( width, mSpilloverBranch->getNominalWidth() ); + addChild(mSpilloverBranch); - break; - } - else - { - // track our rect - height += (*item_iter)->getNominalHeight(); - width = llmax( width, (*item_iter)->getNominalWidth() ); + height += mSpilloverBranch->getNominalHeight(); + width = llmax( width, mSpilloverBranch->getNominalWidth() ); + + break; + } } + // track our rect + height += (*item_iter)->getNominalHeight(); + width = llmax( width, (*item_iter)->getNominalWidth() ); + if (mScrollable) { // Determining visible items boundaries -- cgit v1.3 From ac23d948a483d9194c7d0daef440521c9f4b4b90 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Tue, 16 Sep 2014 16:49:50 +0300 Subject: MAINT-4437 buildfix for linux - removed lambda expression --- indra/llui/llmenugl.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index cb0b75ea48..31df853ab4 100755 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -2114,10 +2114,13 @@ void LLMenuGL::arrange( void ) && height + (*item_iter)->getNominalHeight() > max_height - spillover_item_height) { // don't show only one item - int visible_items = std::count_if(item_iter, mItems.end(), [](LLMenuItemGL* itemp) + int visible_items = 0; + item_list_t::iterator count_iter; + for (count_iter = item_iter; count_iter != mItems.end(); ++count_iter) { - return itemp->getVisible(); - }); + if((*count_iter)->getVisible()) + visible_items++; + } if (visible_items>1) { // no room for any more items -- cgit v1.3 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; --- autobuild.xml | 48 +++++++++++++++++++++++++++++++++++++++++ indra/cmake/CMakeLists.txt | 2 ++ indra/cmake/FindURIPARSER.cmake | 46 +++++++++++++++++++++++++++++++++++++++ indra/cmake/URIPARSER.cmake | 22 +++++++++++++++++++ indra/llui/CMakeLists.txt | 3 +++ indra/llui/lltextbase.cpp | 43 +++++++++++++++++++++++++++++++++++- indra/llui/lltextbase.h | 1 + 7 files changed, 164 insertions(+), 1 deletion(-) create mode 100644 indra/cmake/FindURIPARSER.cmake create mode 100644 indra/cmake/URIPARSER.cmake (limited to 'indra/llui') diff --git a/autobuild.xml b/autobuild.xml index 19fa1b8d82..4fe6725dca 100755 --- a/autobuild.xml +++ b/autobuild.xml @@ -1901,6 +1901,54 @@ + uriparser + + license + uriparser + license_file + LICENSES/uriparser.txt + name + uriparser + platforms + + darwin + + archive + + hash + 99c5a966ac74eea5a505317396152168 + url + http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/3p-uriparser/rev/294299/arch/Darwin/installer/uriparser-0.8.0.1-darwin-20140917.tar.bz2 + + name + darwin + + linux + + archive + + hash + 34306fb90364b182dc770375140d8557 + url + http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/3p-uriparser/rev/294298/arch/Linux/installer/uriparser-0.8.0.1-linux-20140918.tar.bz2 + + name + linux + + windows + + archive + + hash + 73817db47bc0f87269861b7887319414 + url + http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/3p-uriparser/rev/294274/arch/CYGWIN/installer/uriparser-0.8.0.1-windows-20140917.tar.bz2 + + name + windows + + + xmlrpc-epi license diff --git a/indra/cmake/CMakeLists.txt b/indra/cmake/CMakeLists.txt index 10a23ea068..9abdb4b146 100755 --- a/indra/cmake/CMakeLists.txt +++ b/indra/cmake/CMakeLists.txt @@ -37,6 +37,7 @@ set(cmake_SOURCE_FILES FindNDOF.cmake FindOpenJPEG.cmake FindSCP.cmake + FindURIPARSER.cmake FindXmlRpcEpi.cmake FindZLIB.cmake FMODEX.cmake @@ -97,6 +98,7 @@ set(cmake_SOURCE_FILES Tut.cmake UI.cmake UnixInstall.cmake + URIPARSER.cmake Variables.cmake ViewerMiscLibs.cmake VisualLeakDetector.cmake diff --git a/indra/cmake/FindURIPARSER.cmake b/indra/cmake/FindURIPARSER.cmake new file mode 100644 index 0000000000..32457bcd60 --- /dev/null +++ b/indra/cmake/FindURIPARSER.cmake @@ -0,0 +1,46 @@ +# -*- cmake -*- + +# - Find uriparser +# Find the URIPARSER includes and library +# This module defines +# URIPARSER_INCLUDE_DIRS, where to find uriparser.h, etc. +# URIPARSER_LIBRARIES, the libraries needed to use uriparser. +# URIPARSER_FOUND, If false, do not try to use uriparser. +# +# This FindURIPARSER is about 43 times as fast the one provided with cmake (2.8.x), +# because it doesn't look up the version of uriparser, resulting in a dramatic +# speed up for configure (from 4 minutes 22 seconds to 6 seconds). +# +# Note: Since this file is only used for standalone, the windows +# specific parts were left out. + +FIND_PATH(URIPARSER_INCLUDE_DIR uriparser/uri.h + NO_SYSTEM_ENVIRONMENT_PATH + ) + +FIND_LIBRARY(URIPARSER_LIBRARY z) + +if (URIPARSER_LIBRARY AND URIPARSER_INCLUDE_DIR) + SET(URIPARSER_INCLUDE_DIRS ${URIPARSER_INCLUDE_DIR}) + SET(URIPARSER_LIBRARIES ${URIPARSER_LIBRARY}) + SET(URIPARSER_FOUND "YES") +else (URIPARSER_LIBRARY AND URIPARSER_INCLUDE_DIR) + SET(URIPARSER_FOUND "NO") +endif (URIPARSER_LIBRARY AND URIPARSER_INCLUDE_DIR) + +if (URIPARSER_FOUND) + if (NOT URIPARSER_FIND_QUIETLY) + message(STATUS "Found URIPARSER: ${URIPARSER_LIBRARIES}") + SET(URIPARSER_FIND_QUIETLY TRUE) + endif (NOT URIPARSER_FIND_QUIETLY) +else (URIPARSER_FOUND) + if (URIPARSER_FIND_REQUIRED) + message(FATAL_ERROR "Could not find URIPARSER library") + endif (URIPARSER_FIND_REQUIRED) +endif (URIPARSER_FOUND) + +mark_as_advanced( + URIPARSER_LIBRARY + URIPARSER_INCLUDE_DIR + ) + diff --git a/indra/cmake/URIPARSER.cmake b/indra/cmake/URIPARSER.cmake new file mode 100644 index 0000000000..477e142ce5 --- /dev/null +++ b/indra/cmake/URIPARSER.cmake @@ -0,0 +1,22 @@ +# -*- cmake -*- + +set(URIPARSER_FIND_QUIETLY ON) +set(URIPARSER_FIND_REQUIRED ON) + +include(Prebuilt) + +if (STANDALONE) + include(FindURIPARSER) +else (STANDALONE) + use_prebuilt_binary(uriparser) + if (WINDOWS) + set(URIPARSER_LIBRARIES + debug uriparserd + optimized uriparser) + else (WINDOWS) + set(URIPARSER_LIBRARIES z) + endif (WINDOWS) + if (WINDOWS OR LINUX) + set(URIPARSER_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include/uriparser) + endif (WINDOWS OR LINUX) +endif (STANDALONE) 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 +#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()) 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: -- cgit v1.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') 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.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 ++-------------- indra/llui/lltextutil.cpp | 91 +++++++++++++++++++++ indra/llui/lltextutil.h | 29 ++++++- indra/llui/llurlentry.cpp | 30 +++++++ indra/llui/llurlentry.h | 17 ++++ indra/llui/llurlmatch.cpp | 6 +- indra/llui/llurlmatch.h | 6 +- indra/llui/llurlregistry.cpp | 7 +- .../newview/skins/default/textures/icons/hand.png | Bin 0 -> 957 bytes indra/newview/skins/default/textures/textures.xml | 2 + 10 files changed, 191 insertions(+), 67 deletions(-) create mode 100644 indra/newview/skins/default/textures/icons/hand.png (limited to 'indra/llui') 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()) { diff --git a/indra/llui/lltextutil.cpp b/indra/llui/lltextutil.cpp index fff04b34f2..b67daf427b 100755 --- a/indra/llui/lltextutil.cpp +++ b/indra/llui/lltextutil.cpp @@ -30,6 +30,8 @@ #include "lltextbox.h" #include "llurlmatch.h" +#include "uriparser/Uri.h" + boost::function LLTextUtil::TextHelpers::iconCallbackCreationFunction = 0; void LLTextUtil::textboxSetHighlightedVal(LLTextBox *txtbox, const LLStyle::Params& normal_style, const std::string& text, const std::string& hl) @@ -104,4 +106,93 @@ bool LLTextUtil::processUrlMatch(LLUrlMatch* match,LLTextBase* text_base, bool i return false; } +static void textRangeToString(UriTextRangeA& textRange, std::string& str) +{ + S32 len = textRange.afterLast - textRange.first; + if (len) + { + str = textRange.first; + str = str.substr(0, len); + } +} + +S32 LLTextUtil::normalizeUri(std::string& uri_string, Uri * urip/* = NULL*/) +{ + UriParserStateA state; + UriUriA uri; + state.uri = &uri; + + S32 res = uriParseUriA(&state, uri_string.c_str()); + + if (!res) + { + S32 len = uri.scheme.afterLast - uri.scheme.first; + + if (len > 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]; + } + } + } + + // fill urip if requested + if (urip) + { + textRangeToString(uri.scheme, urip->scheme); + textRangeToString(uri.hostText, urip->host); + textRangeToString(uri.portText, urip->port); + textRangeToString(uri.query, urip->query); + textRangeToString(uri.fragment, urip->fragment); + + UriPathSegmentA * pathHead = uri.pathHead; + while (pathHead) + { + std::string partOfPath; + textRangeToString(pathHead->text, partOfPath); + + urip->path += '/'; + urip->path += partOfPath; + + pathHead = pathHead->next; + } + } + } + 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, urip); + uri_string = uri_with_scheme.substr(7); + recursive_call = false; + } + } + } + + uriFreeUriMembersA(&uri); + return res; +} + // EOF diff --git a/indra/llui/lltextutil.h b/indra/llui/lltextutil.h index 798f14d086..176b4ba071 100755 --- a/indra/llui/lltextutil.h +++ b/indra/llui/lltextutil.h @@ -64,7 +64,34 @@ namespace LLTextUtil */ const std::string& formatPhoneNumber(const std::string& phone_str); - bool processUrlMatch(LLUrlMatch* match,LLTextBase* text_base, bool is_content_trusted); + /** + * Adds icon before url if need. + * + * @param[in] match an object with results of matching + * @param[in] text_base pointer to UI text object + * @param[in] is_content_trusted true if context is trusted + * @return reference to string with formatted phone number + */ + bool processUrlMatch(LLUrlMatch* match, LLTextBase* text_base, bool is_content_trusted); + + typedef struct + { + std::string scheme; + std::string host; + std::string port; + std::string path; + std::string query; + std::string fragment; + } Uri; + + /** + * Translates uri's host name and scheme to lowercase + * + * @param[in, out] uri_string string with original uri + * @param[out] uri receives parts of uri + * @return 0 on success, error code otherwise + */ + S32 normalizeUri(std::string& uri_string, Uri * uri = NULL); class TextHelpers { diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp index be583c83d8..3ebf06eefa 100755 --- a/indra/llui/llurlentry.cpp +++ b/indra/llui/llurlentry.cpp @@ -35,6 +35,7 @@ #include "llavatarnamecache.h" #include "llcachename.h" #include "lltrans.h" +#include "lltextutil.h" #include "lluicolortable.h" #include "message.h" @@ -341,6 +342,35 @@ std::string LLUrlEntrySLURL::getLocation(const std::string &url) const return url.substr(pos, url.size() - pos); } +// +// LLUrlEntrySeconlifeURLs Describes *secondlife.com and *lindenlab.com urls to substitute icon 'hand.png' before link +// +LLUrlEntrySeconlifeURL::LLUrlEntrySeconlifeURL() +{ + mPattern = boost::regex("\\b(https?://)?([-\\w\\.]*\\.)?(secondlife|lindenlab)\\.com\\S*", + boost::regex::perl|boost::regex::icase); + + mIcon = "Hand"; + mMenuName = "menu_url_http.xml"; +} + +std::string LLUrlEntrySeconlifeURL::getLabel(const std::string &url, const LLUrlLabelCallback &cb) +{ + std::string local_url(url); + + LLTextUtil::Uri uri; + LLTextUtil::normalizeUri(local_url, &uri); + + return uri.host; +} + +std::string LLUrlEntrySeconlifeURL::getTooltip(const std::string &url) const +{ + std::string local_url(url); + LLTextUtil::normalizeUri(local_url); + return local_url; +} + // // LLUrlEntryAgent Describes a Second Life agent Url, e.g., // secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about diff --git a/indra/llui/llurlentry.h b/indra/llui/llurlentry.h index ffcd45dfde..f75d773803 100755 --- a/indra/llui/llurlentry.h +++ b/indra/llui/llurlentry.h @@ -96,6 +96,8 @@ public: /// Should this link text be underlined only when mouse is hovered over it? virtual bool underlineOnHoverOnly(const std::string &string) const { return false; } + virtual bool isTrusted() const { return false; } + virtual LLUUID getID(const std::string &string) const { return LLUUID::null; } bool isLinkDisabled() const; @@ -167,6 +169,21 @@ public: /*virtual*/ std::string getLocation(const std::string &url) const; }; +/// +/// LLUrlEntrySeconlifeURLs Describes *secondlife.com and *lindenlab.com Urls +/// +class LLUrlEntrySeconlifeURL : public LLUrlEntryBase +{ +public: + LLUrlEntrySeconlifeURL(); + virtual bool isTrusted() const { return true; } + virtual std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb); + virtual std::string getTooltip(const std::string &url) const; + +private: + std::string mLabel; +}; + /// /// LLUrlEntryAgent Describes a Second Life agent Url, e.g., /// secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about diff --git a/indra/llui/llurlmatch.cpp b/indra/llui/llurlmatch.cpp index c1f1382a9f..016d1ca92d 100755 --- a/indra/llui/llurlmatch.cpp +++ b/indra/llui/llurlmatch.cpp @@ -37,7 +37,8 @@ LLUrlMatch::LLUrlMatch() : mIcon(""), mMenuName(""), mLocation(""), - mUnderlineOnHoverOnly(false) + mUnderlineOnHoverOnly(false), + mTrusted(false) { } @@ -45,7 +46,7 @@ void LLUrlMatch::setValues(U32 start, U32 end, const std::string &url, const std::string &label, const std::string &tooltip, const std::string &icon, const LLStyle::Params& style, const std::string &menu, const std::string &location, - const LLUUID& id, bool underline_on_hover_only) + const LLUUID& id, bool underline_on_hover_only, bool trusted) { mStart = start; mEnd = end; @@ -59,4 +60,5 @@ void LLUrlMatch::setValues(U32 start, U32 end, const std::string &url, mLocation = location; mID = id; mUnderlineOnHoverOnly = underline_on_hover_only; + mTrusted = trusted; } diff --git a/indra/llui/llurlmatch.h b/indra/llui/llurlmatch.h index 2818f45207..9f8960b32f 100755 --- a/indra/llui/llurlmatch.h +++ b/indra/llui/llurlmatch.h @@ -80,12 +80,15 @@ public: /// Should this link text be underlined only when mouse is hovered over it? bool underlineOnHoverOnly() const { return mUnderlineOnHoverOnly; } + /// Return true if Url is trusted. + bool isTrusted() const { return mTrusted; } + /// Change the contents of this match object (used by LLUrlRegistry) void setValues(U32 start, U32 end, const std::string &url, const std::string &label, const std::string &tooltip, const std::string &icon, const LLStyle::Params& style, const std::string &menu, const std::string &location, const LLUUID& id, - bool underline_on_hover_only = false ); + bool underline_on_hover_only = false, bool trusted = false ); const LLUUID& getID() const { return mID; } private: @@ -100,6 +103,7 @@ private: LLUUID mID; LLStyle::Params mStyle; bool mUnderlineOnHoverOnly; + bool mTrusted; }; #endif diff --git a/indra/llui/llurlregistry.cpp b/indra/llui/llurlregistry.cpp index ef0789e0e4..462b3d6979 100755 --- a/indra/llui/llurlregistry.cpp +++ b/indra/llui/llurlregistry.cpp @@ -44,6 +44,10 @@ LLUrlRegistry::LLUrlRegistry() mUrlEntryIcon = new LLUrlEntryIcon(); registerUrl(mUrlEntryIcon); registerUrl(new LLUrlEntrySLURL()); + + // decorated links for host names like: secondlife.com and lindenlab.com + registerUrl(new LLUrlEntrySeconlifeURL()); + registerUrl(new LLUrlEntryHTTP()); mUrlEntryHTTPLabel = new LLUrlEntryHTTPLabel(); registerUrl(mUrlEntryHTTPLabel); @@ -212,7 +216,8 @@ bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LL match_entry->getMenuName(), match_entry->getLocation(url), match_entry->getID(url), - match_entry->underlineOnHoverOnly(url)); + match_entry->underlineOnHoverOnly(url), + match_entry->isTrusted()); return true; } diff --git a/indra/newview/skins/default/textures/icons/hand.png b/indra/newview/skins/default/textures/icons/hand.png new file mode 100644 index 0000000000..41b9600da6 Binary files /dev/null and b/indra/newview/skins/default/textures/icons/hand.png differ diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml index 46698b3949..8fdc770009 100755 --- a/indra/newview/skins/default/textures/textures.xml +++ b/indra/newview/skins/default/textures/textures.xml @@ -229,6 +229,8 @@ with the same filename but different name + + -- cgit v1.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/llcommon/CMakeLists.txt | 5 + indra/llcommon/lluriparser.cpp | 228 +++++++++++++++++++++++++++++++++++++++++ indra/llcommon/lluriparser.h | 84 +++++++++++++++ indra/llui/CMakeLists.txt | 3 - indra/llui/lltextbase.cpp | 7 +- indra/llui/lltextutil.cpp | 91 ---------------- indra/llui/lltextutil.h | 19 ---- indra/llui/llurlentry.cpp | 21 ++-- indra/llui/llurlentry.h | 6 +- indra/llui/llurlregistry.cpp | 6 ++ 10 files changed, 338 insertions(+), 132 deletions(-) create mode 100644 indra/llcommon/lluriparser.cpp create mode 100644 indra/llcommon/lluriparser.h (limited to 'indra/llui') diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 763f5a3521..debb42fb5f 100755 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -12,12 +12,14 @@ include(GoogleBreakpad) include(GooglePerfTools) include(Copy3rdPartyLibs) include(ZLIB) +include(URIPARSER) include_directories( ${EXPAT_INCLUDE_DIRS} ${LLCOMMON_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${BREAKPAD_INCLUDE_DIRECTORIES} + ${URIPARSER_INCLUDE_DIRS} ) # add_executable(lltreeiterators lltreeiterators.cpp) @@ -103,6 +105,7 @@ set(llcommon_SOURCE_FILES lltracerecording.cpp lltracethreadrecorder.cpp lluri.cpp + lluriparser.cpp lluuid.cpp llworkerthread.cpp timing.cpp @@ -217,6 +220,7 @@ set(llcommon_HEADER_FILES llunits.h llunittype.h lluri.h + lluriparser.h lluuid.h llwin32headers.h llwin32headerslean.h @@ -261,6 +265,7 @@ target_link_libraries( ${BOOST_PROGRAM_OPTIONS_LIBRARY} ${BOOST_REGEX_LIBRARY} ${GOOGLE_PERFTOOLS_LIBRARIES} + ${URIPARSER_LIBRARIES} ) if (DARWIN) diff --git a/indra/llcommon/lluriparser.cpp b/indra/llcommon/lluriparser.cpp new file mode 100644 index 0000000000..ef4481d32f --- /dev/null +++ b/indra/llcommon/lluriparser.cpp @@ -0,0 +1,228 @@ +/** + * @file lluriparser.cpp + * @author Protey + * @date 2014-10-07 + * @brief Implementation of the LLUriParser class. + * + * $LicenseInfo:firstyear=2014&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2014, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" +#include "lluriparser.h" + +LLUriParser::LLUriParser(const std::string& u) : mTmpScheme(false), mRes(0) +{ + mState.uri = &mUri; + + if (u.find("://") == std::string::npos) + { + mNormalizedUri = "http://"; + mTmpScheme = true; + } + + mNormalizedUri += u.c_str(); + + mRes = parse(); +} + +LLUriParser::~LLUriParser() +{ + uriFreeUriMembersA(&mUri); +} + +S32 LLUriParser::parse() +{ + mRes = uriParseUriA(&mState, mNormalizedUri.c_str()); + return mRes; +} + +const char * LLUriParser::scheme() const +{ + return mScheme.c_str(); +} + +void LLUriParser::sheme(const std::string& s) +{ + mTmpScheme = !s.size(); + mScheme = s; +} + +const char * LLUriParser::port() const +{ + return mPort.c_str(); +} + +void LLUriParser::port(const std::string& s) +{ + mPort = s; +} + +const char * LLUriParser::host() const +{ + return mHost.c_str(); +} + +void LLUriParser::host(const std::string& s) +{ + mHost = s; +} + +const char * LLUriParser::path() const +{ + return mPath.c_str(); +} + +void LLUriParser::path(const std::string& s) +{ + mPath = s; +} + +const char * LLUriParser::query() const +{ + return mQuery.c_str(); +} + +void LLUriParser::query(const std::string& s) +{ + mQuery = s; +} + +const char * LLUriParser::fragment() const +{ + return mFragment.c_str(); +} + +void LLUriParser::fragment(const std::string& s) +{ + mFragment = s; +} + +void LLUriParser::textRangeToString(UriTextRangeA& textRange, std::string& str) +{ + S32 len = textRange.afterLast - textRange.first; + if (len) + { + str = textRange.first; + str = str.substr(0, len); + } +} + +void LLUriParser::extractParts() +{ + if (mTmpScheme) + { + mScheme.clear(); + } + else + { + textRangeToString(mUri.scheme, mScheme); + } + + textRangeToString(mUri.hostText, mHost); + textRangeToString(mUri.portText, mPort); + textRangeToString(mUri.query, mQuery); + textRangeToString(mUri.fragment, mFragment); + + UriPathSegmentA * pathHead = mUri.pathHead; + while (pathHead) + { + std::string partOfPath; + textRangeToString(pathHead->text, partOfPath); + + mPath += '/'; + mPath += partOfPath; + + pathHead = pathHead->next; + } +} + +S32 LLUriParser::normalize() +{ + if (!mRes) + { + mRes = uriNormalizeSyntaxExA(&mUri, URI_NORMALIZE_SCHEME | URI_NORMALIZE_HOST); + + if (!mRes) + { + S32 chars_required; + mRes = uriToStringCharsRequiredA(&mUri, &chars_required); + + if (!mRes) + { + chars_required++; + std::vector label_buf(chars_required); + mRes = uriToStringA(&label_buf[0], &mUri, chars_required, NULL); + + if (!mRes) + { + mNormalizedUri = &label_buf[mTmpScheme ? 7 : 0]; + } + } + } + } + + return mRes; +} + +void LLUriParser::glue(std::string& uri) const +{ + if (mScheme.size()) + { + uri = mScheme; + uri += "://"; + } + + uri += mHost; + + if (mPort.size()) + { + uri += ':'; + uri += mPort; + } + + uri += mPath; + + if (mQuery.size()) + { + uri += '?'; + uri += mQuery; + + if (mFragment.size()) + { + uri += '#'; + uri += mFragment; + } + } +} + +bool LLUriParser::test() const +{ + std::string uri; + glue(uri); + + return uri == mNormalizedUri; +} + +const char * LLUriParser::normalizedUri() const +{ + return mNormalizedUri.c_str(); +} diff --git a/indra/llcommon/lluriparser.h b/indra/llcommon/lluriparser.h new file mode 100644 index 0000000000..719f916837 --- /dev/null +++ b/indra/llcommon/lluriparser.h @@ -0,0 +1,84 @@ +/** + * @file lluriparser.h + * @author Protey + * @date 20146-10-07 + * @brief Declaration of the UriParser class. + * + * $LicenseInfo:firstyear=2014&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2014, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLURIPARSER_H +#define LL_LLURIPARSER_H + +#include +#include "uriparser/Uri.h" + +class LL_COMMON_API LLUriParser +{ +public: + LLUriParser(const std::string& u); + virtual ~LLUriParser(); + + const char * scheme() const; + void sheme (const std::string& s); + + const char * port() const; + void port (const std::string& s); + + const char * host() const; + void host (const std::string& s); + + const char * path() const; + void path (const std::string& s); + + const char * query() const; + void query (const std::string& s); + + const char * fragment() const; + void fragment (const std::string& s); + + const char * normalizedUri() const; + + void extractParts(); + void glue(std::string& uri) const; + bool test() const; + S32 normalize(); + +private: + S32 parse(); + void textRangeToString(UriTextRangeA& textRange, std::string& str); + std::string mScheme; + std::string mHost; + std::string mPort; + std::string mPath; + std::string mQuery; + std::string mFragment; + std::string mNormalizedUri; + + UriParserStateA mState; + UriUriA mUri; + + S32 mRes; + bool mTmpScheme; +}; + +#endif // LL_LLURIPARSER_H diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt index 24fdc2268d..52738aeb6f 100755 --- a/indra/llui/CMakeLists.txt +++ b/indra/llui/CMakeLists.txt @@ -12,7 +12,6 @@ include(LLRender) include(LLWindow) include(LLVFS) include(LLXML) -include(URIPARSER) include_directories( ${LLCOMMON_INCLUDE_DIRS} @@ -29,7 +28,6 @@ include_directories( include_directories(SYSTEM ${LLCOMMON_SYSTEM_INCLUDE_DIRS} ${LLXML_SYSTEM_INCLUDE_DIRS} - ${URIPARSER_INCLUDE_DIRS} ) set(llui_SOURCE_FILES @@ -280,7 +278,6 @@ 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 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()) diff --git a/indra/llui/lltextutil.cpp b/indra/llui/lltextutil.cpp index b67daf427b..fff04b34f2 100755 --- a/indra/llui/lltextutil.cpp +++ b/indra/llui/lltextutil.cpp @@ -30,8 +30,6 @@ #include "lltextbox.h" #include "llurlmatch.h" -#include "uriparser/Uri.h" - boost::function LLTextUtil::TextHelpers::iconCallbackCreationFunction = 0; void LLTextUtil::textboxSetHighlightedVal(LLTextBox *txtbox, const LLStyle::Params& normal_style, const std::string& text, const std::string& hl) @@ -106,93 +104,4 @@ bool LLTextUtil::processUrlMatch(LLUrlMatch* match,LLTextBase* text_base, bool i return false; } -static void textRangeToString(UriTextRangeA& textRange, std::string& str) -{ - S32 len = textRange.afterLast - textRange.first; - if (len) - { - str = textRange.first; - str = str.substr(0, len); - } -} - -S32 LLTextUtil::normalizeUri(std::string& uri_string, Uri * urip/* = NULL*/) -{ - UriParserStateA state; - UriUriA uri; - state.uri = &uri; - - S32 res = uriParseUriA(&state, uri_string.c_str()); - - if (!res) - { - S32 len = uri.scheme.afterLast - uri.scheme.first; - - if (len > 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]; - } - } - } - - // fill urip if requested - if (urip) - { - textRangeToString(uri.scheme, urip->scheme); - textRangeToString(uri.hostText, urip->host); - textRangeToString(uri.portText, urip->port); - textRangeToString(uri.query, urip->query); - textRangeToString(uri.fragment, urip->fragment); - - UriPathSegmentA * pathHead = uri.pathHead; - while (pathHead) - { - std::string partOfPath; - textRangeToString(pathHead->text, partOfPath); - - urip->path += '/'; - urip->path += partOfPath; - - pathHead = pathHead->next; - } - } - } - 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, urip); - uri_string = uri_with_scheme.substr(7); - recursive_call = false; - } - } - } - - uriFreeUriMembersA(&uri); - return res; -} - // EOF diff --git a/indra/llui/lltextutil.h b/indra/llui/lltextutil.h index 176b4ba071..1be81ffd62 100755 --- a/indra/llui/lltextutil.h +++ b/indra/llui/lltextutil.h @@ -74,25 +74,6 @@ namespace LLTextUtil */ bool processUrlMatch(LLUrlMatch* match, LLTextBase* text_base, bool is_content_trusted); - typedef struct - { - std::string scheme; - std::string host; - std::string port; - std::string path; - std::string query; - std::string fragment; - } Uri; - - /** - * Translates uri's host name and scheme to lowercase - * - * @param[in, out] uri_string string with original uri - * @param[out] uri receives parts of uri - * @return 0 on success, error code otherwise - */ - S32 normalizeUri(std::string& uri_string, Uri * uri = NULL); - class TextHelpers { diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp index 3ebf06eefa..c06d6144b9 100755 --- a/indra/llui/llurlentry.cpp +++ b/indra/llui/llurlentry.cpp @@ -31,14 +31,16 @@ #include "lluri.h" #include "llurlmatch.h" #include "llurlregistry.h" +#include "lluriparser.h" #include "llavatarnamecache.h" #include "llcachename.h" #include "lltrans.h" -#include "lltextutil.h" #include "lluicolortable.h" #include "message.h" +#include "uriparser/Uri.h" + #define APP_HEADER_REGEX "((x-grid-location-info://[-\\w\\.]+/app)|(secondlife:///app))" // Utility functions @@ -346,8 +348,8 @@ 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() -{ - mPattern = boost::regex("\\b(https?://)?([-\\w\\.]*\\.)?(secondlife|lindenlab)\\.com\\S*", +{ + mPattern = boost::regex("\\b(https?://)?([-\\w\\.]*\\.)?(secondlife|lindenlab)\\.com(:\\d{1,5})?(/\\S*)?\\b", boost::regex::perl|boost::regex::icase); mIcon = "Hand"; @@ -356,19 +358,14 @@ LLUrlEntrySeconlifeURL::LLUrlEntrySeconlifeURL() std::string LLUrlEntrySeconlifeURL::getLabel(const std::string &url, const LLUrlLabelCallback &cb) { - std::string local_url(url); - - LLTextUtil::Uri uri; - LLTextUtil::normalizeUri(local_url, &uri); - - return uri.host; + LLUriParser up(url); + up.extractParts(); + return up.host(); } std::string LLUrlEntrySeconlifeURL::getTooltip(const std::string &url) const { - std::string local_url(url); - LLTextUtil::normalizeUri(local_url); - return local_url; + return url; } // diff --git a/indra/llui/llurlentry.h b/indra/llui/llurlentry.h index f75d773803..1cb11cdb1c 100755 --- a/indra/llui/llurlentry.h +++ b/indra/llui/llurlentry.h @@ -176,9 +176,9 @@ class LLUrlEntrySeconlifeURL : public LLUrlEntryBase { public: LLUrlEntrySeconlifeURL(); - virtual bool isTrusted() const { return true; } - virtual std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb); - virtual std::string getTooltip(const std::string &url) const; + bool isTrusted() const { return true; } + /*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb); + /*virtual*/ std::string getTooltip(const std::string &url) const; private: std::string mLabel; diff --git a/indra/llui/llurlregistry.cpp b/indra/llui/llurlregistry.cpp index 462b3d6979..9e8d8d01f1 100755 --- a/indra/llui/llurlregistry.cpp +++ b/indra/llui/llurlregistry.cpp @@ -27,6 +27,7 @@ #include "linden_common.h" #include "llurlregistry.h" +#include "lluriparser.h" #include @@ -207,6 +208,11 @@ 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(); + match.setValues(match_start, match_end, match_entry->getUrl(url), match_entry->getLabel(url, cb), -- cgit v1.3