diff --git a/indra/llui/llconsole.cpp b/indra/llui/llconsole.cpp index bdf356eef0..e2e0efee10 100755 --- a/indra/llui/llconsole.cpp +++ b/indra/llui/llconsole.cpp @@ -607,7 +607,10 @@ LLConsole::Paragraph::Paragraph (LLWString str, const LLColor4 &color, F32 add_t label += query; } - LLWStringUtil::replaceString(mParagraphText, utf8str_to_wstring(urlMatch.getUrl()), utf8str_to_wstring(label)); + // This works for LLUrlEntryHTTPLabel and LLUrlEntrySLLabel because + // there is no callback involved for which we are storing the + // matched Url + LLWStringUtil::replaceString(mParagraphText, utf8str_to_wstring(urlMatch.getMatchedText()), utf8str_to_wstring(label)); mUrlLabels[urlMatch.getUrl()] = label; // Remove the URL from the work line so we don't end in a loop in case of regular URLs! diff --git a/indra/llui/llurlmatch.cpp b/indra/llui/llurlmatch.cpp index 2f2ac969e1..a62673c276 100755 --- a/indra/llui/llurlmatch.cpp +++ b/indra/llui/llurlmatch.cpp @@ -46,6 +46,8 @@ void LLUrlMatch::setValues(U32 start, U32 end, const std::string &url, const std const std::string& query, const std::string &tooltip, const std::string &icon, const LLStyle::Params& style, const std::string &menu, const std::string &location, + // Store matched text + const std::string& matched_text, const LLUUID& id, bool underline_on_hover_only, bool trusted) { mStart = start; @@ -62,4 +64,6 @@ void LLUrlMatch::setValues(U32 start, U32 end, const std::string &url, const std mID = id; mUnderlineOnHoverOnly = underline_on_hover_only; mTrusted = trusted; + // Store matched text + mMatchedText = matched_text; } diff --git a/indra/llui/llurlmatch.h b/indra/llui/llurlmatch.h index ff699902ca..a6f6dcf670 100755 --- a/indra/llui/llurlmatch.h +++ b/indra/llui/llurlmatch.h @@ -80,6 +80,9 @@ public: /// return the SL location that this Url describes, or "" if none. std::string getLocation() const { return mLocation; } + // Store matched text + std::string getMatchedText() const { return mMatchedText; } + /// Should this link text be underlined only when mouse is hovered over it? bool underlineOnHoverOnly() const { return mUnderlineOnHoverOnly; } @@ -90,7 +93,10 @@ public: void setValues(U32 start, U32 end, const std::string &url, const std::string &label, const std::string& query, const std::string &tooltip, const std::string &icon, const LLStyle::Params& style, const std::string &menu, - const std::string &location, const LLUUID& id, + // Store matched text + //const std::string &location, const LLUUID& id, + const std::string &location, const std::string& matched_text, const LLUUID& id, + // bool underline_on_hover_only = false, bool trusted = false); const LLUUID& getID() const { return mID; } @@ -104,6 +110,8 @@ private: std::string mIcon; std::string mMenuName; std::string mLocation; + // Store matched text + std::string mMatchedText; LLUUID mID; LLStyle::Params mStyle; bool mUnderlineOnHoverOnly; diff --git a/indra/llui/llurlregistry.cpp b/indra/llui/llurlregistry.cpp index 692a9b1df9..01e5cf50be 100755 --- a/indra/llui/llurlregistry.cpp +++ b/indra/llui/llurlregistry.cpp @@ -340,6 +340,8 @@ bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LL match_entry->getStyle(), match_entry->getMenuName(), match_entry->getLocation(url), + // Store matched text + text.substr(match_start, match_end - match_start + 1), match_entry->getID(url), match_entry->underlineOnHoverOnly(url), match_entry->isTrusted()); @@ -361,7 +363,12 @@ bool LLUrlRegistry::findUrl(const LLWString &text, LLUrlMatch &match, const LLUr // the UTF-8 string because it is a variable-length // 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()); + // Fix for LLUrlEntryHTTPLabel and + // LLUrlEntrySLLabel: Cannot simply replace the URL, + //need to replace the matched text! + //LLWString wurl = utf8str_to_wstring(match.getUrl()); + LLWString wurl = utf8str_to_wstring(match.getMatchedText()); + // size_t start = text.find(wurl); if (start == std::string::npos) { @@ -377,6 +384,8 @@ bool LLUrlRegistry::findUrl(const LLWString &text, LLUrlMatch &match, const LLUr match.getStyle(), match.getMenuName(), match.getLocation(), + // Store matched text + match.getMatchedText(), match.getID(), match.underlineOnHoverOnly()); return true; diff --git a/indra/newview/growlmanager.cpp b/indra/newview/growlmanager.cpp index 5b71527f0a..3bd99a2e8a 100644 --- a/indra/newview/growlmanager.cpp +++ b/indra/newview/growlmanager.cpp @@ -294,7 +294,7 @@ bool GrowlManager::onLLNotification(const LLSD& notice) LLWString workLine = utf8str_to_wstring(body); while (LLUrlRegistry::instance().findUrl(workLine, urlMatch) && !urlMatch.getUrl().empty()) { - LLWStringUtil::replaceString(newLine, utf8str_to_wstring(urlMatch.getUrl()), utf8str_to_wstring(urlMatch.getLabel())); + LLWStringUtil::replaceString(newLine, utf8str_to_wstring(urlMatch.getMatchedText()), utf8str_to_wstring(urlMatch.getLabel())); // Remove the URL from the work line so we don't end in a loop in case of regular URLs! // findUrl will always return the very first URL in a string