diff options
author | Martin Reddy <lynx@lindenlab.com> | 2009-09-23 14:56:02 +0000 |
---|---|---|
committer | Martin Reddy <lynx@lindenlab.com> | 2009-09-23 14:56:02 +0000 |
commit | a0e44e3dd3e09d24ac2d329aa87f4bd34a59f301 (patch) | |
tree | 64257f638c4eb8cf0e6e5027952772fca42640df | |
parent | 47abd559082f6023dcdfadd2ec740195b1d07990 (diff) |
EXT-944 EXT-1026: re-fixing these crashing bugs by making sure
that we don't use character offsets when mixing utf8 and wide
strings. Internal JIRAs: DEV-40127 DEV-39966.
-rw-r--r-- | indra/llui/lltextbox.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp index 810626268f..9de474a4f5 100644 --- a/indra/llui/lltextbox.cpp +++ b/indra/llui/lltextbox.cpp @@ -299,8 +299,9 @@ LLWString LLTextBox::getWrappedText(const LLStringExplicit& in_text, F32 max_wid LLUrlMatch match; while ( LLUrlRegistry::instance().findUrl(wstring_to_utf8str(wtext), match)) { - S32 start = match.getStart(); - S32 end = match.getEnd() + 1; + LLWString wurl = utf8str_to_wstring(match.getUrl()); + S32 start = wtext.find(wurl); + S32 end = start + wurl.size(); // perform word wrap on the text before the Url final_wtext += wrapText(wtext.substr(0, start), hoffset, line_num, max_width); @@ -577,13 +578,17 @@ void LLTextBox::updateDisplayTextAndSegments() boost::bind(&LLTextBox::onUrlLabelUpdated, this, _1, _2)) ) { // work out the char offset for the start/end of the url + LLWString wurl = utf8str_to_wstring(match.getUrl()); + S32 url_start = text.find(wurl); + S32 url_end = url_start + wurl.size() - 1; + S32 seg_start = mDisplayText.size(); - S32 start = seg_start + match.getStart(); - end = start + match.getLabel().size(); + S32 start = seg_start + url_start; + S32 end = start + match.getLabel().size(); // create a segment for the text before the Url mSegments.insert(new LLNormalTextSegment(new LLStyle(), seg_start, start, *this)); - mDisplayText += text.substr(0, match.getStart()); + mDisplayText += text.substr(0, url_start); // create a segment for the Url text LLStyleSP html(new LLStyle); @@ -599,7 +604,7 @@ void LLTextBox::updateDisplayTextAndSegments() mDisplayText += utf8str_to_wstring(match.getLabel()); // move on to the rest of the text after the Url - text = text.substr(match.getEnd()+1, text.size() - match.getEnd()); + text = text.substr(url_end+1, text.size() - url_end); } // output a segment for the remaining text |