FIRE-17187: Fix message with URL containing custom label ([url description]) shows description twice in console and fix wrong start and end indices for LLWString URL matches on the way

master
Ansariel 2015-11-02 11:02:00 +01:00
parent 71a0020438
commit 500cbd17a5
5 changed files with 28 additions and 4 deletions

View File

@ -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!

View File

@ -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,
// <FS:Ansariel> 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;
// <FS:Ansariel> Store matched text
mMatchedText = matched_text;
}

View File

@ -80,6 +80,9 @@ public:
/// return the SL location that this Url describes, or "" if none.
std::string getLocation() const { return mLocation; }
// <FS:Ansariel> 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,
// <FS:Ansariel> Store matched text
//const std::string &location, const LLUUID& id,
const std::string &location, const std::string& matched_text, const LLUUID& id,
// </FS:Ansariel>
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;
// <FS:Ansariel> Store matched text
std::string mMatchedText;
LLUUID mID;
LLStyle::Params mStyle;
bool mUnderlineOnHoverOnly;

View File

@ -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),
// <FS:Ansariel> 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());
// <FS:Ansariel> 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());
// </FS:Ansariel>
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(),
// <FS:Ansariel> Store matched text
match.getMatchedText(),
match.getID(),
match.underlineOnHoverOnly());
return true;

View File

@ -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