From 7aa859b7f4212e0e8177539284eaef6dfad57d94 Mon Sep 17 00:00:00 2001 From: Martin Reddy Date: Fri, 16 Oct 2009 14:04:23 +0000 Subject: EXT-1566: Fixed another case of UTF-8 vs UTF-32 coding error for SLURL parsing in text editors. Any time we are looking up segment start/end ranges we should do this on a wide string. Also added a convenience LLUrlRegistry::hasUrl() method to easily determine if a string contains a valid SLURL. --- indra/llui/lltexteditor.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'indra/llui/lltexteditor.cpp') diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 74ffad0f53..7c925b8899 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -2505,6 +2505,8 @@ void LLTextEditor::updateSegments() void LLTextEditor::updateLinkSegments() { + LLWString wtext = getWText(); + // update any segments that contain a link for (segment_set_t::iterator it = mSegments.begin(); it != mSegments.end(); ++it) { @@ -2514,13 +2516,13 @@ void LLTextEditor::updateLinkSegments() // if the link's label (what the user can edit) is a valid Url, // then update the link's HREF to be the same as the label text. // This lets users edit Urls in-place. - LLUrlMatch match; LLStyleSP style = static_cast(segment->getStyle()); - std::string url_label = getText().substr(segment->getStart(), segment->getEnd()-segment->getStart()); - if (LLUrlRegistry::instance().findUrl(url_label, match)) + LLWString url_label = wtext.substr(segment->getStart(), segment->getEnd()-segment->getStart()); + if (LLUrlRegistry::instance().hasUrl(url_label)) { - LLStringUtil::trim(url_label); - style->setLinkHREF(url_label); + std::string new_url = wstring_to_utf8str(url_label); + LLStringUtil::trim(new_url); + style->setLinkHREF(new_url); } } } -- cgit v1.2.3