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.2.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.2.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.2.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; --- indra/llui/CMakeLists.txt | 3 +++ indra/llui/lltextbase.cpp | 43 ++++++++++++++++++++++++++++++++++++++++++- indra/llui/lltextbase.h | 1 + 3 files changed, 46 insertions(+), 1 deletion(-) (limited to 'indra/llui') 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.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') 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 ++++------------------------------ 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 +++- 8 files changed, 189 insertions(+), 67 deletions(-) (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; } -- 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/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 +++ 7 files changed, 21 insertions(+), 132 deletions(-) (limited to 'indra/llui') 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.2.3