Bug 124986 - FILEOPEN DOCX: "text:variable-set" field has trailing quotation marks in "office:string-value"
Summary: FILEOPEN DOCX: "text:variable-set" field has trailing quotation marks in "off...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
5.4.7.2 release
Hardware: All All
: medium normal
Assignee: Oliver Brinzing
URL:
Whiteboard: target:6.4.0 target:6.3.4
Keywords: bibisected, bisected
Depends on:
Blocks:
 
Reported: 2019-04-26 17:13 UTC by Oliver Brinzing
Modified: 2019-11-30 17:19 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
demo doxc file (11.48 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2019-04-26 17:13 UTC, Oliver Brinzing
Details
comparison MSO 2010 and LibreOffice 6.4 Master (8.37 KB, image/png)
2019-10-22 12:15 UTC, Xisco Faulí
Details
screenshot_word_2016_vs_lo_master (136.12 KB, image/png)
2019-10-22 17:28 UTC, Oliver Brinzing
Details
demo with and without trailing space (11.73 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2019-11-01 14:45 UTC, Oliver Brinzing
Details
DomainMapper_Impl.PNG (134.50 KB, image/png)
2019-11-01 15:28 UTC, Oliver Brinzing
Details
demo with and without trailing/leading spaces (11.82 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2019-11-01 16:17 UTC, Oliver Brinzing
Details
set_var_test.bas - macro for testcase (615 bytes, text/plain)
2019-11-04 18:29 UTC, Oliver Brinzing
Details
set_var_test.docx - data file for testcase (11.82 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2019-11-04 18:30 UTC, Oliver Brinzing
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Brinzing 2019-04-26 17:13:49 UTC
Created attachment 151026 [details]
demo doxc file

opening a *.docx file with "text:variable-set" fields adds a trailing quotation mark to attribute "office:string-value"

xml representation after *.docx import:

<text:p text:style-name="P1">
 <text:variable-set text:name="_marker_start" text:display="none" 
   text:formula="ooow:demo&quot;" office:value-type="string" 
   office:string-value="demo&quot;"/>
Hello
 <text:variable-set text:name="_marker_ende" text:display="none" 
  text:formula="ooow:demo&quot;" office:value-type="string" 
  office:string-value="demo&quot;"/>
</text:p>

no problem with *.doc import
Comment 1 Xisco Faulí 2019-10-22 12:15:07 UTC
Created attachment 155233 [details]
comparison MSO 2010 and LibreOffice 6.4 Master
Comment 2 Xisco Faulí 2019-10-22 12:16:43 UTC
Dear Oliver,
Could you please try to reproduce it with a master build from http://dev-builds.libreoffice.org/daily/master/ ?
You can install it alongside the standard version.
I have set the bug's status to 'NEEDINFO'. Please change it back to 'UNCONFIRMED' if the bug is still present in the master build
Comment 3 Oliver Brinzing 2019-10-22 17:28:13 UTC
Created attachment 155243 [details]
screenshot_word_2016_vs_lo_master

(In reply to Xisco Faulí from comment #2)

yes it's still reproducible with:

Version: 6.4.0.0.alpha1+ (x64)
Build ID: 2e81c006b85214d28927ae4e3e18eda5f3be944a
CPU threads: 4; OS: Windows 10.0 Build 18362; UI render: default; VCL: win; 
Locale: de-DE (de_DE); UI-Language: en-US
Calc: threaded
Comment 4 QA Administrators 2019-10-24 02:41:58 UTC Comment hidden (obsolete)
Comment 5 Oliver Brinzing 2019-11-01 14:45:57 UTC
Created attachment 155447 [details]
demo with and without trailing space

the problem seems to be the trailing space
Comment 6 Oliver Brinzing 2019-11-01 14:56:16 UTC
this seems to have started with:

https://gerrit.libreoffice.org/plugins/gitiles/core/+/4d5ce76d894d2335b551f8c2b29437e2049894f0

commit 4d5ce76d894d2335b551f8c2b29437e2049894f0	[log]
author	Jean-Sebastien Bevilacqua <realitix@gmail.com>
Thu Feb 16 10:16:50 2017 +0100
committer	Miklos Vajna <vmiklos@collabora.co.uk>	
Tue Mar 28 07:05:30 2017 +0000
tree 152ac7f5dabfc7f7cb1df385dac8ed63a3afa1d1
parent b3549aacabffad3c4c66d901938d59e4789eef22 [diff]

tdf#105975 Add Set field parsing (docx) in LibreOffice Writer

Introduction
------------

In MSWord, you can create a variable with `SET` field and then
reference it later in a formula. When you save your file as `docx`,
this `SET` field is registered in you file. In its current state,
LibreOffice can't parse the `SET` field in `docx` file.

Context of this fix
-------------------

This fix is entirely located in the `DomainMapper_Impl.cxx` file
because it's where the parsing is done.

How this fix works
------------------

First, we add `SET` support by adding it to the `aFields[]` variable.
Next, to handle the `SET` constant, we add a condition (swith case) in
`DomainMapper_Impl::CloseFieldCommand()` to call `handleFieldSet`.
Finally, `handleFieldSet` works like `handleFieldAsk` with small
differences.

Note
----

I have renamed `lcl_ExctractAskVariableAndHint` to
`lcl_ExctractVariableAndHint` because this function is used for both `ASK` and
`SET` fields.

Change-Id: I2bf948e26e8506ac151d1d0bc8556721bbe0392b
Reviewed-on: https://gerrit.libreoffice.org/34333
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>

/cygdrive/d/sources/bibisect/bibisect-win32-5.4
$ git bisect good c20d8357a586fc4616a4352d0f39117492da0bc0 is the first bad commit
commit c20d8357a586fc4616a4352d0f39117492da0bc0
Author: Norbert Thiebaud <nthiebaud@gmail.com>
Date:   Tue Mar 28 00:50:59 2017 -0700
    source 4d5ce76d894d2335b551f8c2b29437e2049894f0
    source 4d5ce76d894d2335b551f8c2b29437e2049894f0

:040000 040000 bf860248cec2620dfeeda7b75779bc849fd54475 cfc1f8b4ae15560de2dabfeb868973df7a2c303a M      instdir

/cygdrive/d/sources/bibisect/bibisect-win32-5.4
$ git bisect log
# bad: [5b9390199c309eb0f061804e45031da85989a8ef] source 534fd9aacd3eea10070a3ee88fc654eb9791aa24
# good: [633bfe84509c1953415e5dd0f564098a16890131] source 4136757b4e51c4e6f7cb4132c95538a7f831ef2c
git bisect start 'master' 'oldest'
# good: [fb6ad3d5a416ac122c263bb29a8d1b90a0750432] source 055c8cc676921176e2b9df76bd0e09bacab1d80b
git bisect good fb6ad3d5a416ac122c263bb29a8d1b90a0750432
# bad: [e4ec339892e747e2dfd56126e74a90411fced190] source a917902c48f21d04039da86048c5c36555137d7e
git bisect bad e4ec339892e747e2dfd56126e74a90411fced190
# good: [374673a7108c11f5a2d352f522597414093decbc] source dfdf256d828e29b430e41d1b82899680664259f5
git bisect good 374673a7108c11f5a2d352f522597414093decbc
# bad: [a868c68624daf768ba20fb4f4acf5d0fef543edd] source 8005237d71a75fe9bcfd860111bb0fe1fa6064d6
git bisect bad a868c68624daf768ba20fb4f4acf5d0fef543edd
# bad: [6ce293ed08bec72f7ae1a219f81c35a85b5b84ed] source 0e261a6908c2521a9967069095239eeb02810b8c
git bisect bad 6ce293ed08bec72f7ae1a219f81c35a85b5b84ed
# bad: [5757440d796f875b1392b645825b1f9ea08e56f8] source 2f2296d2c328fa8bf3671f8d3591d3a2bdf2752f
git bisect bad 5757440d796f875b1392b645825b1f9ea08e56f8
# bad: [cab5d9b720db39f4b1f8701695cf34195b17cb55] source 799824565b783ec0b2323bd609a0e69a70182ac1
git bisect bad cab5d9b720db39f4b1f8701695cf34195b17cb55
# good: [ac97714fa1fd6359420656e6e0591954e4038576] source 2fc5ef74c5200bdb82cdbbc812d7ac05a9a489dd
git bisect good ac97714fa1fd6359420656e6e0591954e4038576
# bad: [741fb160c0ac3408f5b02b0c4f98119573ecfc17] source 0cb5435dd35674b6e55e22922a0819d2a755fc10
git bisect bad 741fb160c0ac3408f5b02b0c4f98119573ecfc17
# bad: [8bef32fdac27565c8ddd500424359c5654be6368] source 65aa28cc1c8a90865c3a9ea379722730c40ecb53
git bisect bad 8bef32fdac27565c8ddd500424359c5654be6368
# bad: [b1140d3e2c8263b05bb80c3f5bfabe6901037754] source 157cb703888f4187c2c6709b13ebf9f779580fe2
git bisect bad b1140d3e2c8263b05bb80c3f5bfabe6901037754
# bad: [c20d8357a586fc4616a4352d0f39117492da0bc0] source 4d5ce76d894d2335b551f8c2b29437e2049894f0
git bisect bad c20d8357a586fc4616a4352d0f39117492da0bc0
# good: [3482471497813663a77c7baa97558d0b8b0dd933] source b3549aacabffad3c4c66d901938d59e4789eef22
git bisect good 3482471497813663a77c7baa97558d0b8b0dd933
# first bad commit: [c20d8357a586fc4616a4352d0f39117492da0bc0] source 4d5ce76d894d2335b551f8c2b29437e2049894f0
Comment 7 Oliver Brinzing 2019-11-01 15:27:11 UTC
i think, i found the problem in "DomainMapper_Impl.cxx", will try to fix
Comment 8 Oliver Brinzing 2019-11-01 15:28:43 UTC
Created attachment 155450 [details]
DomainMapper_Impl.PNG
Comment 9 Oliver Brinzing 2019-11-01 16:17:34 UTC
Created attachment 155453 [details]
demo with and without trailing/leading spaces
Comment 10 Oliver Brinzing 2019-11-02 06:04:04 UTC
added a patch:

tdf#124986: docx: remove trailing quotation marks and spaces from set fields
https://gerrit.libreoffice.org/#/c/81892/

waiting for review
Comment 11 Oliver Brinzing 2019-11-04 18:29:40 UTC
Created attachment 155509 [details]
set_var_test.bas - macro for testcase
Comment 12 Oliver Brinzing 2019-11-04 18:30:11 UTC
Created attachment 155510 [details]
set_var_test.docx - data file for testcase
Comment 13 Commit Notification 2019-11-11 08:55:28 UTC
brinzing committed a patch related to this issue.
It has been pushed to "master":

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

tdf#124986: docx: remove trailing quotation marks and spaces from set fields

It will be available in 6.4.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 14 Oliver Brinzing 2019-11-13 17:07:52 UTC
Looks good for me at master.

Is there a chance to backport to LO 6.3?
Comment 15 Commit Notification 2019-11-15 12:53:06 UTC
brinzing committed a patch related to this issue.
It has been pushed to "libreoffice-6-3":

https://git.libreoffice.org/core/commit/0c4c7452671b137dc70c329a34ba271428caab9a

tdf#124986: docx: remove trailing quotation marks and spaces from set fields

It will be available in 6.3.4.

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.