Bug 133377 - FILESAVE DOCX: Date Document properties mangled during FileOpen/FileSave using Word 2007-365 .docx format
Summary: FILESAVE DOCX: Date Document properties mangled during FileOpen/FileSave usin...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
6.4.3.2 release
Hardware: All All
: medium normal
Assignee: Bartosz
URL:
Whiteboard: target:7.1.0 target:7.0.3
Keywords: filter:docx
Depends on:
Blocks: DOCX File-Properties
  Show dependency treegraph
 
Reported: 2020-05-25 14:57 UTC by rhardy
Modified: 2021-03-14 15:25 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Screenshot showing mangled ISO 8601 DocReleasedDate field (73.66 KB, image/png)
2020-05-25 14:57 UTC, rhardy
Details
Sample document showing failure mode (5.34 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2020-05-25 18:07 UTC, rhardy
Details
DateTest2 screenshot (69.31 KB, image/png)
2020-05-28 14:05 UTC, rhardy
Details
DataTest2.odt file (8.91 KB, application/vnd.oasis.opendocument.text)
2020-05-28 14:08 UTC, rhardy
Details
DateTest2.docx file (5.38 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2020-05-28 14:14 UTC, rhardy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description rhardy 2020-05-25 14:57:39 UTC
Created attachment 161266 [details]
Screenshot showing mangled ISO 8601 DocReleasedDate field

It is fairly common in environments where document version control is in place to want to set Custom document properties such as DocVersion or DocReleasedDate and use those fields in the document. Unfortunately the current version of LibreOffice Writer on Ubuntu 20.04 is mangling those to the point of not being able to use them. Please fix to Date field isn't changed to DateTime field with invalid data.

To reproduce this bug:
1. Start from a blank document in Writer. Edit Document Properties and add a Custom property of DocReleasedDate and pick type Date (not DateTime) and select 2020-05-25 i.e. use an ISO 8601 standard date format.
2. Type This is a test. and add the field DocReleasedDate
3. Add a Header and type This is a header test. and add the field DocReleasedDate
4. SaveAs the file as DateTest.docx using Word 2007-365 .docx filter.
5. Re open the file and find the date format with garbage 0025-01-02 and custom property changed from Date to DateTime with invalid data.

Version: 6.4.3.2
Build ID: 1:6.4.3-0ubuntu0.20.04.1
CPU threads: 4; OS: Linux 5.4; UI render: default; VCL: gtk3; 
Locale: en-CA (en_CA.UTF-8); UI-Language: en-US
Calc: threaded
Comment 1 rhardy 2020-05-25 15:01:26 UTC
Ah well when I made the screenshot I actually used DocDateReleased instead of DocReleasedDate but the field name doesn't matter. It fails the same way no matter what you name the customer document property...
Comment 2 Xisco Faulí 2020-05-25 15:42:02 UTC
Thank you for reporting the bug. Please attach a sample document, as this makes it easier for us to verify the bug. 
I have set the bug's status to 'NEEDINFO'. Please change it back to 'UNCONFIRMED' once the requested document is provided.
(Please note that the attachment will be public, remove any sensitive information before attaching it. 
See https://wiki.documentfoundation.org/QA/FAQ#How_can_I_eliminate_confidential_data_from_a_sample_document.3F for help on how to do so.)
Comment 3 rhardy 2020-05-25 18:07:19 UTC
Created attachment 161272 [details]
Sample document showing failure mode

Please note after you SaveAs in Word 2007-365 .docx format both the displayed fields are correct and when you look in Document properties the custom properties we added it still shows correctly as type Date. The problem arises when you close Writer and reopen the file that was saved. Then the date type document property gets mangled to DateTime format with the erroneous data and is displayed incorrectly. Please find attached a sample DateTest.docx document.
Comment 4 rhardy 2020-05-25 18:09:07 UTC
Attachment provides requested sample. Problem is displayed on FILEOPEN after a SaveAs of a new document.
Comment 5 Dieter 2020-05-28 12:22:59 UTC
(In reply to rhardy from comment #3)
> Created attachment 161272 [details]
> Sample document showing failure mode

Thanks for the document. But please provide a odt-file (after step 3 of your steps to repoduce). This makes it possible to compare dte format before and after saving as docx. Thanks

=> NEEDINFO
Comment 6 rhardy 2020-05-28 14:05:17 UTC
Created attachment 161372 [details]
DateTest2 screenshot

Screenshot showing failure mode after DateTest2.docx file is opened.
Comment 7 rhardy 2020-05-28 14:08:01 UTC
Created attachment 161373 [details]
DataTest2.odt file

DateTest2.odt file with correct Custom Document Property DocDateReleased.
This displays properly using ISO 8601 date format.
Comment 8 rhardy 2020-05-28 14:14:14 UTC
Created attachment 161374 [details]
DateTest2.docx file

Loaded DateTest2.odf and SaveAs DateTest2.docx using Word 2007-365 docx filter. Note when reopening the DataTest2.dox file shows a mangled Custom Document property and displays incorrectly. The DataTest2 screenshot uploaded previously shows this. It only happens after you close and reopen the DataTest2.docx file.
Comment 9 rhardy 2020-05-28 14:18:57 UTC
Comment on attachment 161374 [details]
DateTest2.docx file

I loaded DateTest2.odt and SaveAs DateTest2.docx using Word 2007-365 docx filter. Note when reopening the DateTest2.docx file it shows a mangled Custom Document property and displays dates incorrectly. The DateTest2 screenshot uploaded which shows this. It only appears in the UI after you close and reopen the DateTest2.docx file.
Comment 10 rhardy 2020-05-28 14:20:18 UTC
Provided updated files as requested.
Comment 11 Dieter 2020-05-29 15:44:39 UTC
I confirm it with

Version: 7.0.0.0.beta1 (x64)
Build ID: 94f789cbb33335b4a511c319542c7bdc31ff3b3c
CPU threads: 4; OS: Windows 10.0 Build 18363; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: en-GB
Calc: CL

Steps to reproduce
1. Open file from comment 7
2. File => Properties => Custom Properties => Type is "Date"
3. Save as docx
4. File => Properties => Custom Properties => Type is "Date"
5. Close and Reopen file in writer
6. File => Properties => Custom Properties => Type is "DateTime"

Additional information: Can't open dock-file with Word 2016
Comment 12 Bartosz 2020-10-16 14:21:06 UTC
The date in custom.xml is saved in different order by LibreOffice.
It is saved:

    <property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="3" name="DocReleasedDate">
        <vt:filetime>20-10-2017T00:00:00Z</vt:filetime>
    </property>

and it should be:

   <property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="3" name="DocReleasedDate">
        <vt:filetime>2017-10-20T00:00:00Z</vt:filetime>
    </property>


After manual fixing everything is opening smoothly.
Comment 13 Commit Notification 2020-10-17 10:45:06 UTC
Bartosz Kosiorek committed a patch related to this issue.
It has been pushed to "master":

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

tdf#133377 OOXML Fix storage of date in Custom Properties

It will be available in 7.1.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 Commit Notification 2020-10-17 15:06:45 UTC
Bartosz Kosiorek committed a patch related to this issue.
It has been pushed to "libreoffice-7-0":

https://git.libreoffice.org/core/commit/5dda71e33e8d7e5b6433b7c3b48115c6738a177f

tdf#133377 OOXML Fix storage of date in Custom Properties

It will be available in 7.0.3.

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 15 Dieter 2020-11-01 11:41:04 UTC
(In reply to Commit Notification from comment #14)
> It will be available in 7.0.3.

I can still reproduce the problem with steps from comment 11 with

Version: 7.0.3.1 (x64)
Build ID: d7547858d014d4cf69878db179d326fc3483e082
CPU threads: 4; OS: Windows 10.0 Build 19042; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: en-GB
Calc: threaded
Comment 16 Bartosz 2020-11-10 19:40:47 UTC
@Dieter(In reply to Dieter from comment #15)
> (In reply to Commit Notification from comment #14)
> > It will be available in 7.0.3.
> 
> I can still reproduce the problem with steps from comment 11 with

The issue from the bug description was already resolved. To reproduce the issue please follow steps:

1. Start from a blank document in Writer. Edit Document Properties and add a Custom property of DocReleasedDate and pick type Date (not DateTime) and select 2020-05-25 i.e. use an ISO 8601 standard date format.
2. Type This is a test. and add the field DocReleasedDate
3. Add a Header and type This is a header test. and add the field DocReleasedDate
4. SaveAs the file as DateTest.docx using Word 2007-365 .docx filter.
5. Re open the file and find the date format with garbage 0025-01-02 and custom property changed from Date to DateTime with invalid data.