Bug 100105 - RTF Export: invalid un-closed \fldrslt exported for hyperlink
Summary: RTF Export: invalid un-closed \fldrslt exported for hyperlink
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.4.0.3 release
Hardware: All All
: medium normal
Assignee: Michael Stahl
QA Contact:
URL:
Whiteboard: target:5.3.0 target:5.2.0.1 target:5.1.5
Keywords: bibisected, bisected, filter:rtf, regression
Depends on:
Blocks: RTF
  Show dependency treegraph
 
Reported: 2016-05-28 13:14 UTC by Monika Edvardsen
Modified: 2016-10-25 18:54 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments
rtf-document gone blank (3.70 KB, application/rtf)
2016-05-28 13:14 UTC, Monika Edvardsen
Details
Screencast of document going blank and then not (2.41 MB, video/mp4)
2016-06-06 11:35 UTC, Monika Edvardsen
Details
Test document saved in 4.4.0.3 (buggy) (2.36 KB, application/rtf)
2016-06-13 05:17 UTC, Aron Budea
Details
Test document saved in 4.3.0.4 (working) (2.19 KB, application/rtf)
2016-06-13 05:18 UTC, Aron Budea
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Monika Edvardsen 2016-05-28 13:14:10 UTC
Created attachment 125349 [details]
rtf-document gone blank

Hello,
This has happened with v5.1.1.2, the previous version (I think), and also Apache OpenOffice in their 2015/2016 versions. I believe it's the same thing on all the computers I've used LibreOffice and OpenOffice on (They are Mac OSX, Win 7 x32, Win 8 x64, Win 10 x64).
I've tested doing this (with some small variations) 20 times in a row: 
Paste a link at the top of the rtf document, save and close
Open, go to the start of the link, press enter and write something on the top line, save and close
And the document goes blank again and again. Sometimes one line is left, and sometimes I can see a line in Preview but nothing in the open document.

The attachment is just a blank file, but maybe you can see beyond that with your tools???! As I said, I've written stuff and saved it about 20 times so it SHOULD be something there, but I have no idea, hehe...
Comment 1 Shinji Enoki 2016-05-29 06:53:36 UTC
I can not reproduce in the following environment.

OS: Debian jessie
Version: 5.1.3.2
Build ID: 644e4637d1d8544fd9f56425bd6cec110e49301b
CPU Threads: 4; OS Version: Linux 3.16; UI Render: default; 
Locale: en-US (ja_JP.utf8)
Comment 2 Monika Edvardsen 2016-05-29 15:06:17 UTC
What do you mean? That everything works as it should on your system? 
Or that you can't see anything in the attached document?
M.
Comment 3 raal 2016-05-31 05:31:06 UTC
I can not reproduce with Version: 5.3.0.0.alpha0+
Build ID: 33d4f7e5624d77ef1ce51aece1c8a0ef7ea21603
CPU Threads: 1; OS Version: Windows 6.1; UI Render: default; 
TinderBox: Win-x86@42, Branch:master, Time: 2016-05-29_01:58:16
and 5.1.3
Text is not lost.

In your RTF file I see the link (not in writer, but when open with notepad). Please could you attach video with reproduction steps, maybe we missed something. Thank you.
Comment 4 Theodore Matula Jr. 2016-06-02 21:10:43 UTC
I also cannot reproduce this bug with version 5.2.0.0alpha1+ in Windows 10. I opened the attached file in notepad++ and saw a link, but when I opened it in writer, the document was blank. I also preformed the following test. As Raal said, could you go more into detail about the reproduction steps and your environment?

Steps to reproduce:
1. Open then attached RTF document (it is blank in writer)
2. Type in a URL, save the document in RTF format, and close it.
3. Open the RTF document again
4. Press enter while the text input cursor is in front of the URL
5. Type some words in the line above the URL
6. Save the document and close it again.
7. Reopen the document

Expected Result: the document has the words typed in step 5, followed by the URL in the next line

Actual Result: the document has the words typed in step 5, followed by the URL in the next line

Version: 5.2.0.0.alpha1+
Build ID: cc1a0ba927ad6f85103059aa8e6108017f436304
CPU Threads: 8; OS Version: Windows 6.2; UI Render: default; 
TinderBox: Win-x86@62-merge-TDF, Branch:MASTER, Time: 2016-05-17_02:31:19
Locale: en-US (en_US)
Comment 5 Monika Edvardsen 2016-06-06 11:35:31 UTC
Created attachment 125512 [details]
Screencast of document going blank and then not

Probably goes without saying, but to be 100% clear: I used Cmd + V, cmd + S and cmd + W
Comment 6 Monika Edvardsen 2016-06-06 11:36:46 UTC
Sorry for delayed reply.

As I said before, this happens in different environments:

- Mac 10.9.5, Version: 5.1.2.2. It happens also with Apache OpenOffice - except in OpenOffice the words written above the link is still there when I open the document.

- Win 8.1, Version 5.1.2.2, also OpenOffice

- Win 10, Version 5.1.2.2 and 5.1.3, also OpenOffice

I just do this:
Type a link on top of the document
Press enter while the text input cursor is in front of the URL
Write something on the line above the URL
Save (as rtf) and close
Open it and it's blank almost every time.

However, it does not go blank when I do this:
Type a link on top of the document
Press enter while the text input cursor is in front of the URL
Write something in front of and on the same line as the URL
Press enter
Save (as rtf) and close

That none of you can reproduce as you say, I really don't understand as it happens on all computers I've tried it on, all on my home network. Could it be something with my network? There's nothing to be found with Malwarebytes, Superantispyware, Avast or Bitdefender on any of the computers.
Comment 7 Aron Budea 2016-06-13 05:17:42 UTC
Created attachment 125627 [details]
Test document saved in 4.4.0.3 (buggy)

Reproduced based on steps described in Comment 6, starting from 4.4.0.3 to 5.2 beta2, not reproducible with 4.3.0.4, this is a regression. Attaching samples saved in both versions. Also reproduced in Linux with 5.5.0.2.

Steps taken to produce attached doc:
start with empty document, insert hyperlink, press Home, press Enter, press Up, write "test", save as RTF.
Comment 8 Aron Budea 2016-06-13 05:18:45 UTC
Created attachment 125628 [details]
Test document saved in 4.3.0.4 (working)
Comment 9 raal 2016-06-13 07:39:56 UTC
This seems to have begun at the below commit.
Adding Cc: to Michael Stahl; Could you possibly take a look at this one? Thanks

1a2f1c300d35805384d51aa9641934e4a71b256b is the first bad commit
commit 1a2f1c300d35805384d51aa9641934e4a71b256b
Author: Norbert Thiebaud <nthiebaud@gmail.com>
Date:   Thu May 14 03:45:32 2015 -0500

    source sha:0f78ae1ca33f83737553ad204c869a63498b7d2d
author	Michael Stahl <mstahl@redhat.com>	2014-12-15 20:19:01 (GMT)
committer	Michael Stahl <mstahl@redhat.com>	2014-12-15 21:18:13 (GMT)
commit	0f78ae1ca33f83737553ad204c869a63498b7d2d (patch)
tree	86a945e082534b12d8b04bbce616e6793776cd3b
parent	6d8ab70f1da785767e539383087258bd666fbf62 (diff)
fdo#85876: Revert "fdo#74981: cutting nothing should do nothing, ...
Comment 10 Michael Stahl 2016-06-15 13:58:39 UTC
this must be a regression in the RTF export that was masked by the wrong fix for bug 74981 that was being reverted by the commit in comment #9 (which is obviously correct)

in 4.2.3.2 i get this:

\pgndec\pard\plain \s0\nowidctlpar{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\cf0\kerning1\dbch\af5\langfe2052\dbch\af6\afs24\alang1081\loch\f3\fs24\lang1031{{\field{\*\fldinst HYPERLINK "http://example.com/" }\rtlch \ltrch\loch
}test}

but current master produces a \fldrslt group that it doesn't close:

{\*\ftnsep\chftnsep}\pgndec\pard\plain \s0\widctlpar\hyphpar0\cf0\kerning1\dbch\af5\langfe2052\dbch\af6\afs24\alang1081\loch\f3\fs24\lang1031{}}}{\field{\*\fldinst HYPERLINK "http://example.com/" }{\fldrslt {\rtlch \ltrch\loch
test}
Comment 11 Michael Stahl 2016-06-15 14:51:32 UTC
apparently this is what broke it:

commit b8907bf3d3b37c686a414ffbbd2d732348aab5b9
Author:     Michael Stahl <mstahl@redhat.com>
AuthorDate: Fri Jun 27 16:02:45 2014 +0200

    fdo#78758: sw: RTF export: don't export multiple \fldrst for one hyperlink
    
    Ensure that we export only one \fldresult per hyperlink by doing that in
    StartURL() and EndURL(); the TextINetFormat() is called once per text
    portion.  This shouldn't cause problems as there can't be anything
    between the end of the \field group and the start of \fldresult anyway.
Comment 12 Michael Stahl 2016-06-15 16:16:04 UTC
fixed on master
Comment 13 Commit Notification 2016-06-15 16:16:26 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=b4855bd63c05096df1a2da339133f243bb30d902

tdf#100105 sw: RTF export: fix empty hyperlinks

It will be available in 5.3.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 14 Commit Notification 2016-06-15 21:39:37 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-5-2":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=744bd590fd2c39638e8df41a569cb2cc376e7450&h=libreoffice-5-2

tdf#100105 sw: RTF export: fix empty hyperlinks

It will be available in 5.2.0.1.

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

Affected users are encouraged to test the fix and report feedback.
Comment 15 Monika Edvardsen 2016-06-19 16:10:36 UTC
I've tried the Mac version of the 5.2.1 daily build now, and the problem is gone - hooray and thank you very much! Looking forward to the Windows version. 
Thanks again,
Monika
Comment 16 Aron Budea 2016-06-25 04:04:48 UTC
Confirmed working in 5.2.0.1.
Since this bug can produce invalid RTF documents, requesting backport to 5.1.
Comment 17 Commit Notification 2016-06-27 12:16:35 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-5-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=f687c57465292e940f9e0d69aa2e4ee3376bd569&h=libreoffice-5-1

tdf#100105 sw: RTF export: fix empty hyperlinks

It will be available in 5.1.5.

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

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