diff options
| author | VolkSec <luan.nutels@owasp.org> | 2026-08-24 16:02:10 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-24 22:02:10 +0300 |
| commit | a402fd4da91bbce03340e174505c06feede65866 (patch) | |
| tree | cf0c2efeed99f129cecd145b9a22eeba4a821a41 /indra/llui/lltexteditor.cpp | |
| parent | 0da385368a875bfc204adb14b970b818a642e854 (diff) | |
#5871 Handle trailing line breaks when pasting text (#6069)
Signed-off-by: Luan Nutels - VolkSec <luan.nutels@owasp.org>
Diffstat (limited to 'indra/llui/lltexteditor.cpp')
| -rw-r--r-- | indra/llui/lltexteditor.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 5f1302df88..6588c481ff 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -1693,28 +1693,25 @@ void LLTextEditor::pasteTextWithLinebreaks(LLWString & clean_string) std::basic_string<llwchar>::size_type start = 0; std::basic_string<llwchar>::size_type pos = clean_string.find('\n',start); - while((pos != -1) && (pos != clean_string.length() -1)) + while (pos != std::basic_string<llwchar>::npos) { - if(pos!=start) + if (pos != start) { std::basic_string<llwchar> str = std::basic_string<llwchar>(clean_string,start,pos-start); setCursorPos(mCursorPos + insert(mCursorPos, str, true, LLTextSegmentPtr())); } - addLineBreakChar(true); // Add a line break and group with the next addition. + const bool trailing_linebreak = (pos == clean_string.length() - 1); + addLineBreakChar(!trailing_linebreak); start = pos+1; pos = clean_string.find('\n',start); } - if (pos != start) + if (start < clean_string.length()) { std::basic_string<llwchar> str = std::basic_string<llwchar>(clean_string,start,clean_string.length()-start); setCursorPos(mCursorPos + insert(mCursorPos, str, false, LLTextSegmentPtr())); } - else - { - addLineBreakChar(false); // Add a line break and end the grouping. - } } // copy selection to primary |
