From 12762053e5aff372a9f8d473c71aa81e805bb474 Mon Sep 17 00:00:00 2001 From: Martin Reddy Date: Tue, 22 Sep 2009 18:00:16 +0000 Subject: EXT-944 EXT-1026: converted the LLUrlRegistry::findUrl() method to work on an LLWString instead of a std::string, so that we don't have to worry about character offsets for variable-length-encoded UTF-8 strings. This was causing crashes whenever we would try to show a textbox with a URL and foreign characters (> 1 byte chars). Damn, I suck! --- indra/llui/lltexteditor.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'indra/llui/lltexteditor.cpp') diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 983777b747..f7680a0a2b 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -3525,7 +3525,7 @@ void LLTextEditor::appendStyledText(const std::string &new_text, S32 start=0,end=0; LLUrlMatch match; - std::string text = new_text; + LLWString text = utf8str_to_wstring(new_text); while ( LLUrlRegistry::instance().findUrl(text, match, boost::bind(&LLTextEditor::onUrlLabelUpdated, this, _1, _2)) ) { @@ -3549,8 +3549,8 @@ void LLTextEditor::appendStyledText(const std::string &new_text, { part = (S32)LLTextParser::MIDDLE; } - std::string subtext=text.substr(0,start); - appendHighlightedText(subtext,allow_undo, prepend_newline, part, style_params); + std::string subtext = wstring_to_utf8str(text.substr(0,start)); + appendHighlightedText(subtext, allow_undo, prepend_newline, part, style_params); prepend_newline = false; } @@ -3595,7 +3595,8 @@ void LLTextEditor::appendStyledText(const std::string &new_text, } } if (part != (S32)LLTextParser::WHOLE) part=(S32)LLTextParser::END; - if (end < (S32)text.length()) appendHighlightedText(text,allow_undo, prepend_newline, part, style_params); + if (end < (S32)text.length()) appendHighlightedText(wstring_to_utf8str(text), allow_undo, + prepend_newline, part, style_params); } else { @@ -4137,7 +4138,7 @@ void LLTextEditor::updateLinkSegments() 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)) + if (LLUrlRegistry::instance().findUrl(utf8str_to_wstring(url_label), match)) { LLStringUtil::trim(url_label); style->setLinkHREF(url_label); -- cgit v1.2.3