From 02ce7e9afffb5261cc223a4d66b2d0e1ebc832fa Mon Sep 17 00:00:00 2001 From: Jim Easterbrook Date: Mon, 15 Nov 2021 10:18:05 +0000 Subject: [PATCH 1/3] Restore modified tags after TZ manipulation This ensures that Xmp date/times that have been set by the user aren't over written by the TZ restoration efforts. This fixes bug #1998 --- src/xmpsidecar.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/xmpsidecar.cpp b/src/xmpsidecar.cpp index 70f26019..1f88b8dd 100644 --- a/src/xmpsidecar.cpp +++ b/src/xmpsidecar.cpp @@ -144,11 +144,6 @@ namespace Exiv2 { copyExifToXmp(exifData_, xmpData_); copyIptcToXmp(iptcData_, xmpData_); - // #589 - restore tags which were modified by the convertors - for (auto&& it : copy) { - xmpData_[it.key()] = it.value(); - } - // #1112 - restore dates if they lost their TZ info for (auto&& date : dates_) { std::string sKey = date.first; @@ -163,6 +158,11 @@ namespace Exiv2 { } } + // #589 - restore tags which were modified by the convertors + for (auto&& it : copy) { + xmpData_[it.key()] = it.value(); + } + if (XmpParser::encode(xmpPacket_, xmpData_, XmpParser::omitPacketWrapper|XmpParser::useCompactFormat) > 1) { #ifndef SUPPRESS_WARNINGS From da3b36f242fd04ce3bb6a6cc453bd5d7bd362efe Mon Sep 17 00:00:00 2001 From: Jim Easterbrook Date: Wed, 1 Dec 2021 10:02:59 +0000 Subject: [PATCH 2/3] Add test files for PR 1999 / issue 1998 --- test/data/issue_1998.xmp | 9 +++++++++ tests/bugfixes/github/test_pr_1999.py | 28 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 test/data/issue_1998.xmp create mode 100644 tests/bugfixes/github/test_pr_1999.py diff --git a/test/data/issue_1998.xmp b/test/data/issue_1998.xmp new file mode 100644 index 00000000..c1b84fa4 --- /dev/null +++ b/test/data/issue_1998.xmp @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/tests/bugfixes/github/test_pr_1999.py b/tests/bugfixes/github/test_pr_1999.py new file mode 100644 index 00000000..6f270a01 --- /dev/null +++ b/tests/bugfixes/github/test_pr_1999.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +import system_tests +from system_tests import CaseMeta, path + +class TestXmpDateTimeSetting(metaclass=CaseMeta): + """ + Test fix for issue 1998. + """ + + infile = path("$data_path/issue_1998.xmp") + commands = [ + "$exiv2 -M'set Xmp.xmp.CreateDate XmpText 2021-02-03T12:00:00+01:00' $infile", + "$exiv2 -K Xmp.xmp.CreateDate $infile", + "$exiv2 -M'set Xmp.xmp.CreateDate XmpText 2021-02-03T12:34:56+02:00' $infile", + "$exiv2 -K Xmp.xmp.CreateDate $infile", + ] + stdout = [ + """""", + """Xmp.xmp.CreateDate XmpText 25 2021-02-03T12:00:00+01:00 +""", + """""", + """Xmp.xmp.CreateDate XmpText 25 2021-02-03T12:34:56+02:00 +""", + ] + stderr = [""]*4 + retval = [0]*4 + From 2e2dd887e30c1ef6897a68be392840decf4891cb Mon Sep 17 00:00:00 2001 From: Jim Easterbrook Date: Wed, 1 Dec 2021 10:17:25 +0000 Subject: [PATCH 3/3] Use \" instead of ' for exiv2 command string The original failed on some Windows test runs. --- tests/bugfixes/github/test_pr_1999.py | 56 +++++++++++++-------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/tests/bugfixes/github/test_pr_1999.py b/tests/bugfixes/github/test_pr_1999.py index 6f270a01..ef6e4b64 100644 --- a/tests/bugfixes/github/test_pr_1999.py +++ b/tests/bugfixes/github/test_pr_1999.py @@ -1,28 +1,28 @@ -# -*- coding: utf-8 -*- - -import system_tests -from system_tests import CaseMeta, path - -class TestXmpDateTimeSetting(metaclass=CaseMeta): - """ - Test fix for issue 1998. - """ - - infile = path("$data_path/issue_1998.xmp") - commands = [ - "$exiv2 -M'set Xmp.xmp.CreateDate XmpText 2021-02-03T12:00:00+01:00' $infile", - "$exiv2 -K Xmp.xmp.CreateDate $infile", - "$exiv2 -M'set Xmp.xmp.CreateDate XmpText 2021-02-03T12:34:56+02:00' $infile", - "$exiv2 -K Xmp.xmp.CreateDate $infile", - ] - stdout = [ - """""", - """Xmp.xmp.CreateDate XmpText 25 2021-02-03T12:00:00+01:00 -""", - """""", - """Xmp.xmp.CreateDate XmpText 25 2021-02-03T12:34:56+02:00 -""", - ] - stderr = [""]*4 - retval = [0]*4 - +# -*- coding: utf-8 -*- + +import system_tests +from system_tests import CaseMeta, path + +class TestXmpDateTimeSetting(metaclass=CaseMeta): + """ + Test fix for issue 1998. + """ + + infile = path("$data_path/issue_1998.xmp") + commands = [ + "$exiv2 -M\"set Xmp.xmp.CreateDate XmpText 2021-02-03T12:00:00+01:00\" $infile", + "$exiv2 -K Xmp.xmp.CreateDate $infile", + "$exiv2 -M\"set Xmp.xmp.CreateDate XmpText 2021-02-03T12:34:56+02:00\" $infile", + "$exiv2 -K Xmp.xmp.CreateDate $infile", + ] + stdout = [ + "", + """Xmp.xmp.CreateDate XmpText 25 2021-02-03T12:00:00+01:00 +""", + "", + """Xmp.xmp.CreateDate XmpText 25 2021-02-03T12:34:56+02:00 +""", + ] + stderr = [""]*4 + retval = [0]*4 +