Bug 102625 - Formula editor breaks surrogate pairs
Summary: Formula editor breaks surrogate pairs
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Formula Editor (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium minor
Assignee: Julien Nabet
URL:
Whiteboard: target:7.0.0 target:6.4.5
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-27 13:16 UTC by bug.reporter.21
Modified: 2020-05-09 09:52 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bug.reporter.21 2016-09-27 13:16:52 UTC
LO 5152
Steps :
1) open LO
2) File -> New -> Formula
3) In the editor field, insert a character with code above U+10000 (for example: '𝑛')
4) click in the middle of the character
5) press the space bar
6) text is now broken.
Comment 1 Buovjaga 2016-10-09 16:26:51 UTC
Repro.

Arch Linux 64-bit, KDE Plasma 5
Version: 5.3.0.0.alpha0+
Build ID: ff2a399b61f34f7920e594e8cbb6c19045b24956
CPU Threads: 8; OS Version: Linux 4.7; UI Render: default; 
Locale: fi-FI (fi_FI.UTF-8); Calc: group
Built on October 7th 2016

Arch Linux 64-bit
LibreOffice 3.3.0 
OOO330m19 (Build:6)
tag libreoffice-3.3.0.4
Comment 2 QA Administrators 2017-10-23 14:12:57 UTC Comment hidden (obsolete)
Comment 3 QA Administrators 2019-12-03 13:53:21 UTC Comment hidden (obsolete)
Comment 4 Julien Nabet 2020-05-05 22:14:17 UTC
On pc Debian x86-64 with master sources updated today, I got a crash.

There's indeed a pb when dealing with surrogate.
See part of bt when typing space after having clicking on middle of 𝑛 character:
#0  SmParser::Parse(rtl::OUString const&) (this=0x3205db8, rBuffer="\xd835 \xdc5b") at starmath/source/parse.cxx:2381
#1  0x00007fffdc3981e3 in SmDocShell::Parse() (this=0x3205c20) at starmath/source/document.cxx:222
#2  0x00007fffdc397e7c in SmDocShell::SetText(rtl::OUString const&) (this=0x3205c20, rBuffer="\xd835 \xdc5b\n") at starmath/source/document.cxx:145
#3  0x00007fffdc3973c8 in SmDocShell::Execute(SfxRequest&) (this=0x3205c20, rReq=...) at starmath/source/document.cxx:1034

There shouldn't be an extra space here: "\xd835 \xdc5b"

The crash is triggered by https://cgit.freedesktop.org/libreoffice/core/commit/?id=11b57129b53e1e2d71a5f969e2417226b4e2ddd9 but it just makes the bug worse, it didn't create it.

I don't understand how come typing space may indeed insert a space between a pair of surrogates in rBuffer.
Comment 5 Julien Nabet 2020-05-05 22:26:30 UTC
In SmTextForwarder::GetText, pEditEngine->GetText( rSel ) has already the pb.

https://opengrok.libreoffice.org/xref/core/starmath/source/accessibility.cxx?r=9ad252b2#885
Comment 6 Julien Nabet 2020-05-07 20:49:39 UTC
I gave a try with https://gerrit.libreoffice.org/c/core/+/93684
Comment 7 Commit Notification 2020-05-08 09:03:23 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/23efced60cb7e08bf17b10e3e1ea5802e68a0cc6

tdf#102625: fix Formula editor breaks surrogate pairs

It will be available in 7.0.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 8 Julien Nabet 2020-05-08 09:17:11 UTC
Backport for 6.4 waiting for review here:
https://gerrit.libreoffice.org/c/core/+/93544
Comment 9 Buovjaga 2020-05-08 17:44:49 UTC
Verified, thanks!

Arch Linux 64-bit
Version: 7.0.0.0.alpha1+
Build ID: bd8015b13636607805fcf6a25e353597db868696
CPU threads: 8; OS: Linux 5.6; UI render: default; VCL: kf5; 
Locale: fi-FI (fi_FI.UTF-8); UI: en-US
Calc: threaded
Built on 8 May 2020
Comment 10 Commit Notification 2020-05-09 09:52:17 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "libreoffice-6-4":

https://git.libreoffice.org/core/commit/f7661f9da338daedc0a215bab76f4b0b42538913

tdf#102625: fix Formula editor breaks surrogate pairs

It will be available in 6.4.5.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.