From b6bf20a897091cc582d95c8aaa7e978cd01b96f2 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Fri, 11 Dec 2020 15:10:35 +0000 Subject: [PATCH 1/7] fix_1431_binary_comment. --- src/value.cpp | 17 ----------------- test/data/exiv2-bug528.jpg | Bin 10302 -> 10305 bytes tests/bugfixes/redmine/test_issue_528.py | 10 +++++----- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/src/value.cpp b/src/value.cpp index 5bd815e2e7..b96f7de350 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -555,18 +555,6 @@ namespace Exiv2 { return os << comment(); } - // test string for printable ascii-7 (' ' .. '~') - static bool isBinary(const std::string& s) - { - bool result = false ; - size_t i = 0; - while ( !result && i < s.length() ) { - unsigned char c = (unsigned char) s[i++]; - result = c < 32 || c > 127 ; - } - return result; - } - std::string CommentValue::comment(const char* encoding) const { std::string c; @@ -583,11 +571,6 @@ namespace Exiv2 { if ( bAscii && c.find('\0') != c.std::string::npos) { c = c.substr(0,c.find('\0')); } - // return "binary comment" if results contains non-printable bytes - // this ensures no binary bytes in the output stream. - if ( bAscii && isBinary(c) ) { - c = "binary comment" ; - } return c; } diff --git a/test/data/exiv2-bug528.jpg b/test/data/exiv2-bug528.jpg index cde81de25989a23fac62e7d3a0b4c032d216bf9e..4921b4076722cafe30b57ff0a949a86e12a53981 100644 GIT binary patch delta 302 zcmdlNa4=wkIODd765hOj7zG%Z7#JA%7#J9tCKiYr3NT7DumS}bfk=W;gMk^$1}b4R z1S{kQvJ@DNz-$p9TW8`9eL;r~RR$J_CgwB-2Ie0Ve<)6tU^JNQ&ZxwDtZ6RHM5c3- z%NX@-uT5Zq>1TR1k&%HNsFj70iJ4&%BLf%27^Z)dm|(h?*(R~T#F_afKVnpt6q{57 z)+GeAOm0#en5_n68%&mCisubm#1GdSH@S=H5XeIe43h(y#hG*zCTB9+N*(}u4CHSn gSC9+~SUJ$E%r_?QXBKDtF!?%jD5KJ5T^2zV0K1$l!~g&Q delta 337 zcmX>YurFYOIOFDt65hPO83h=a7#JA%7#J8CCl-hs@-s>^umS}bfk>QDgMk^$1}b4R z1S{kQvg8?!z-$p9TWjJDeL=epRR$J_Cgx-Y2Ij95e<)6tV$`4P#i+=8q-ie9M5Z&7 zD;V`{uS{Tp>1TQ|k&%HNsFj70iJ4&%BLf%27^Xjym|(h?SthZ-#F=>}KVejs6q!^5 z)+GeAOlDFWn5_zA>rGZ*isubp#1GdSJ-LVJkgQ{{v!^G}Wao^;lGMb~3WbzZg`7kM zpZv_CRIbT6%(jMmfj$KV1d}U}0D1-#20*_vUj?#&VFAVr3~X?7-%h^89Lgxa*?>h* F1pxWVGQ$7> diff --git a/tests/bugfixes/redmine/test_issue_528.py b/tests/bugfixes/redmine/test_issue_528.py index c17c49bbd4..b7ce0e8a2c 100644 --- a/tests/bugfixes/redmine/test_issue_528.py +++ b/tests/bugfixes/redmine/test_issue_528.py @@ -30,7 +30,7 @@ class TypeSizeForExifOnly(metaclass=system_tests.CaseMeta): Exif.Image.YCbCrPositioning Short 1 Centered Exif.Image.Rating SLong 1 3 Exif.Image.RatingPercent SLong 1 50 -Exif.Image.ExifTag Long 1 318 +Exif.Image.ExifTag Long 1 320 Exif.Photo.ExposureTime Rational 1 1/250 s Exif.Photo.FNumber Rational 1 F11 Exif.Photo.ExposureProgram Short 1 Auto @@ -46,10 +46,10 @@ class TypeSizeForExifOnly(metaclass=system_tests.CaseMeta): Exif.Photo.Flash Short 1 No, compulsory Exif.Photo.FocalLength Rational 1 10.0 mm Exif.Photo.MakerNote Undefined 18 0 1 2 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 -Exif.MakerNote.Offset Long 1 796 +Exif.MakerNote.Offset Long 1 798 Exif.MakerNote.ByteOrder Ascii 3 MM Exif.Canon.0x0200 0x0300 0 -Exif.Photo.UserComment Undefined 37 charset=Ascii binary comment +Exif.Photo.UserComment Undefined 38 Chateaux de la Loire, Chambord Exif.Photo.SubSecTime Ascii 3 81 Exif.Photo.SubSecTimeOriginal Ascii 3 81 Exif.Photo.SubSecTimeDigitized Ascii 3 81 @@ -66,7 +66,7 @@ class TypeSizeForExifOnly(metaclass=system_tests.CaseMeta): Exif.Photo.SceneCaptureType Short 1 Standard Exif.Photo.Contrast Short 1 Normal Exif.Photo.Saturation Short 1 Normal -Exif.Image.GPSTag Long 1 867 +Exif.Image.GPSTag Long 1 870 Exif.GPSInfo.GPSVersionID Byte 4 2.0.0.0 Exif.GPSInfo.GPSLatitudeRef Ascii 2 North Exif.GPSInfo.GPSLatitude Rational 3 47deg 36' 58" @@ -75,7 +75,7 @@ class TypeSizeForExifOnly(metaclass=system_tests.CaseMeta): Exif.GPSInfo.GPSAltitudeRef Byte 1 Above sea level Exif.GPSInfo.GPSAltitude Rational 1 86 m Exif.Thumbnail.Compression Short 1 JPEG (old-style) -Exif.Thumbnail.JPEGInterchangeFormat Long 1 1055 +Exif.Thumbnail.JPEGInterchangeFormat Long 1 1058 Exif.Thumbnail.JPEGInterchangeFormatLength Long 1 4492 """, """File 1/1: $filename From ecae9dc6eba437d9ef568e3b3b377932ff76f309 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Sun, 13 Dec 2020 20:55:17 +0000 Subject: [PATCH 2/7] Restored 0.27.2 "toString()" behaviour of Exifdatum.value().toString() for CommentValue. --- src/exif.cpp | 12 ++++++++++-- src/value.cpp | 4 ---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/exif.cpp b/src/exif.cpp index 493fd20b92..78c8ae0837 100644 --- a/src/exif.cpp +++ b/src/exif.cpp @@ -226,8 +226,16 @@ namespace Exiv2 { if ( ti ) { fct = ti->printFct_; if ( ti->typeId_ == comment ) { - os << value().toString(); - fct=NULL; + fct=NULL; + const Exiv2::CommentValue* cv = dynamic_cast(&value()); + Exiv2::CommentValue::CharsetId csId = cv->charsetId(); + if ( csId != CommentValue::undefined ) { + os << "charset=" << CommentValue::CharsetInfo::name(csId) << " "; + } + os << cv->comment(); +#if 0 + os << "|| value().toString() = " << value().toString(); +#endif } } if ( fct ) fct(os, value(), pMetadata); diff --git a/src/value.cpp b/src/value.cpp index b96f7de350..9999782218 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -548,10 +548,6 @@ namespace Exiv2 { std::ostream& CommentValue::write(std::ostream& os) const { - CharsetId csId = charsetId(); - if (csId != undefined) { - os << "charset=" << CharsetInfo::name(csId) << " "; - } return os << comment(); } From 23f39b60f709e4e08d47a644ddfdde44dbf51cc2 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Mon, 14 Dec 2020 10:31:32 +0000 Subject: [PATCH 3/7] Fixing test suite. --- src/actions.cpp | 12 ++++++++++-- src/exif.cpp | 12 ------------ src/tags_int.cpp | 17 ++++++++++++++--- src/tags_int.hpp | 2 ++ test/data/exifdata-test.out | 8 ++++---- 5 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/actions.cpp b/src/actions.cpp index a6f885a16c..9cffc7dc61 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -599,8 +599,16 @@ namespace Action { std::cout << " "; first = false; std::ostringstream os; - // #1114 - show negative values for SByte - if (md.typeId() == Exiv2::signedByte) { + // 1431 always translate "comment" tags to show charset= + // sadly md.key() cannot access tagInfo.typeId_ (== comment) + Exiv2::StringSet commentTags; + commentTags.insert("Exif.Photo.UserComment"); + commentTags.insert("Exif.GPSInfo.GPSProcessingMethod"); + commentTags.insert("Exif.GPSInfo.GPSAreaInformation"); + if ( commentTags.find(md.key()) != commentTags.end() ) { + os << md.print(&pImage->exifData()); + } else if (md.typeId() == Exiv2::signedByte) { + // #1114 - show negative values for SByte for ( int c = 0 ; c < md.value().count() ; c++ ) { int value = md.value().toLong(c); os << (c?" ":"") << std::dec << (value < 128 ? value : value - 256); diff --git a/src/exif.cpp b/src/exif.cpp index 78c8ae0837..04e6d76396 100644 --- a/src/exif.cpp +++ b/src/exif.cpp @@ -225,18 +225,6 @@ namespace Exiv2 { // be careful with comments (User.Photo.UserComment, GPSAreaInfo etc). if ( ti ) { fct = ti->printFct_; - if ( ti->typeId_ == comment ) { - fct=NULL; - const Exiv2::CommentValue* cv = dynamic_cast(&value()); - Exiv2::CommentValue::CharsetId csId = cv->charsetId(); - if ( csId != CommentValue::undefined ) { - os << "charset=" << CommentValue::CharsetInfo::name(csId) << " "; - } - os << cv->comment(); -#if 0 - os << "|| value().toString() = " << value().toString(); -#endif - } } if ( fct ) fct(os, value(), pMetadata); return os; diff --git a/src/tags_int.cpp b/src/tags_int.cpp index 1f9499fabb..4c9563aac2 100644 --- a/src/tags_int.cpp +++ b/src/tags_int.cpp @@ -1776,7 +1776,7 @@ namespace Exiv2 { N_("A tag for Exif users to write keywords or comments on the image " "besides those in , and without the " "character code limitations of the tag."), - exifId, userInfo, comment, 0, printValue), + exifId, userInfo, comment, 0, printComment), TagInfo(0x9290, "SubSecTime", N_("Sub-seconds Time"), N_("A tag used to record fractions of seconds for the tag."), exifId, dateTime, asciiString, 0, printValue), @@ -2204,11 +2204,11 @@ namespace Exiv2 { TagInfo(0x001b, "GPSProcessingMethod", N_("GPS Processing Method"), N_("A character string recording the name of the method used for location finding. " "The string encoding is defined using the same scheme as UserComment."), - gpsId, gpsTags, comment, 0, printValue), + gpsId, gpsTags, comment, 0, printComment), TagInfo(0x001c, "GPSAreaInformation", N_("GPS Area Information"), N_("A character string recording the name of the GPS area." "The string encoding is defined using the same scheme as UserComment."), - gpsId, gpsTags, comment, 0, printValue), + gpsId, gpsTags, comment, 0, printComment), TagInfo(0x001d, "GPSDateStamp", N_("GPS Date Stamp"), N_("A character string recording date and time information relative to UTC " "(Coordinated Universal Time). The format is \"YYYY:MM:DD.\"."), @@ -2461,6 +2461,17 @@ namespace Exiv2 { return os << value; } + std::ostream& printComment(std::ostream& os, const Value& value, const ExifData*) + { + const Exiv2::CommentValue* cv = dynamic_cast(&value); + Exiv2::CommentValue::CharsetId csId = cv->charsetId(); + if ( csId != CommentValue::undefined ) { + os << "charset=" << CommentValue::CharsetInfo::name(csId) << " "; + } + os << cv->comment(); + return os ; + } + std::ostream& printBitmask(std::ostream& os, const Value& value, const ExifData* metadata) { if (value.typeId() == Exiv2::unsignedShort || value.typeId() == Exiv2::signedShort) diff --git a/src/tags_int.hpp b/src/tags_int.hpp index 694624cc11..cbd22c4f19 100644 --- a/src/tags_int.hpp +++ b/src/tags_int.hpp @@ -362,6 +362,8 @@ namespace Exiv2 { //@{ //! Default print function, using the Value output operator std::ostream& printValue(std::ostream& os, const Value& value, const ExifData*); + //! Print the value of a comment + std::ostream& printComment(std::ostream& os, const Value& value, const ExifData*); //! Print the value converted to a long std::ostream& printLong(std::ostream& os, const Value& value, const ExifData*); //! Print a Rational or URational value in floating point format diff --git a/test/data/exifdata-test.out b/test/data/exifdata-test.out index 2605f0e23b..1cc1479cad 100644 --- a/test/data/exifdata-test.out +++ b/test/data/exifdata-test.out @@ -819,7 +819,7 @@ Exif.NikonFl1.0x0011 0x0011 Makernote Byte 3 Exif.Nikon3.ImageOptimization 0x00a9 Makernote Ascii 16 NORMAL Exif.Nikon3.Saturation 0x00aa Makernote Ascii 16 NORMAL Exif.Nikon3.VariProgram 0x00ab Makernote Ascii 16 -Exif.Photo.UserComment 0x9286 Exif Undefined 44 charset=Ascii +Exif.Photo.UserComment 0x9286 Exif Undefined 44 Exif.Photo.SubSecTime 0x9290 Exif Ascii 3 00 Exif.Photo.SubSecTimeOriginal 0x9291 Exif Ascii 3 00 Exif.Photo.SubSecTimeDigitized 0x9292 Exif Ascii 3 00 @@ -990,7 +990,7 @@ Exif.NikonFl1.0x0011 0x0011 Makernote Byte 3 Exif.Nikon3.ImageOptimization 0x00a9 Makernote Ascii 16 NORMAL Exif.Nikon3.Saturation 0x00aa Makernote Ascii 16 NORMAL Exif.Nikon3.VariProgram 0x00ab Makernote Ascii 16 -Exif.Photo.UserComment 0x9286 Exif Undefined 44 charset=Ascii +Exif.Photo.UserComment 0x9286 Exif Undefined 44 Exif.Photo.SubSecTime 0x9290 Exif Ascii 3 00 Exif.Photo.SubSecTimeOriginal 0x9291 Exif Ascii 3 00 Exif.Photo.SubSecTimeDigitized 0x9292 Exif Ascii 3 00 @@ -1162,7 +1162,7 @@ Exif.NikonFl1.0x0011 0x0011 Makernote Byte 3 Exif.Nikon3.ImageOptimization 0x00a9 Makernote Ascii 16 NORMAL Exif.Nikon3.Saturation 0x00aa Makernote Ascii 16 NORMAL Exif.Nikon3.VariProgram 0x00ab Makernote Ascii 16 -Exif.Photo.UserComment 0x9286 Exif Undefined 44 charset=Ascii +Exif.Photo.UserComment 0x9286 Exif Undefined 44 Exif.Photo.SubSecTime 0x9290 Exif Ascii 3 00 Exif.Photo.SubSecTimeOriginal 0x9291 Exif Ascii 3 00 Exif.Photo.SubSecTimeDigitized 0x9292 Exif Ascii 3 00 @@ -1334,7 +1334,7 @@ Exif.NikonFl1.0x0011 0x0011 Makernote Byte 3 Exif.Nikon3.ImageOptimization 0x00a9 Makernote Ascii 16 NORMAL Exif.Nikon3.Saturation 0x00aa Makernote Ascii 16 NORMAL Exif.Nikon3.VariProgram 0x00ab Makernote Ascii 16 -Exif.Photo.UserComment 0x9286 Exif Undefined 44 charset=Ascii +Exif.Photo.UserComment 0x9286 Exif Undefined 44 Exif.Photo.SubSecTime 0x9290 Exif Ascii 3 00 Exif.Photo.SubSecTimeOriginal 0x9291 Exif Ascii 3 00 Exif.Photo.SubSecTimeDigitized 0x9292 Exif Ascii 3 00 From af8699a8accd3a8ac5f553c8e37296b2852965a8 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Mon, 14 Dec 2020 20:01:03 +0000 Subject: [PATCH 4/7] Revert "Fixing test suite." This reverts commit 23f39b60f709e4e08d47a644ddfdde44dbf51cc2. --- src/actions.cpp | 12 ++---------- src/exif.cpp | 12 ++++++++++++ src/tags_int.cpp | 17 +++-------------- src/tags_int.hpp | 2 -- test/data/exifdata-test.out | 8 ++++---- 5 files changed, 21 insertions(+), 30 deletions(-) diff --git a/src/actions.cpp b/src/actions.cpp index 9cffc7dc61..a6f885a16c 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -599,16 +599,8 @@ namespace Action { std::cout << " "; first = false; std::ostringstream os; - // 1431 always translate "comment" tags to show charset= - // sadly md.key() cannot access tagInfo.typeId_ (== comment) - Exiv2::StringSet commentTags; - commentTags.insert("Exif.Photo.UserComment"); - commentTags.insert("Exif.GPSInfo.GPSProcessingMethod"); - commentTags.insert("Exif.GPSInfo.GPSAreaInformation"); - if ( commentTags.find(md.key()) != commentTags.end() ) { - os << md.print(&pImage->exifData()); - } else if (md.typeId() == Exiv2::signedByte) { - // #1114 - show negative values for SByte + // #1114 - show negative values for SByte + if (md.typeId() == Exiv2::signedByte) { for ( int c = 0 ; c < md.value().count() ; c++ ) { int value = md.value().toLong(c); os << (c?" ":"") << std::dec << (value < 128 ? value : value - 256); diff --git a/src/exif.cpp b/src/exif.cpp index 04e6d76396..78c8ae0837 100644 --- a/src/exif.cpp +++ b/src/exif.cpp @@ -225,6 +225,18 @@ namespace Exiv2 { // be careful with comments (User.Photo.UserComment, GPSAreaInfo etc). if ( ti ) { fct = ti->printFct_; + if ( ti->typeId_ == comment ) { + fct=NULL; + const Exiv2::CommentValue* cv = dynamic_cast(&value()); + Exiv2::CommentValue::CharsetId csId = cv->charsetId(); + if ( csId != CommentValue::undefined ) { + os << "charset=" << CommentValue::CharsetInfo::name(csId) << " "; + } + os << cv->comment(); +#if 0 + os << "|| value().toString() = " << value().toString(); +#endif + } } if ( fct ) fct(os, value(), pMetadata); return os; diff --git a/src/tags_int.cpp b/src/tags_int.cpp index 4c9563aac2..1f9499fabb 100644 --- a/src/tags_int.cpp +++ b/src/tags_int.cpp @@ -1776,7 +1776,7 @@ namespace Exiv2 { N_("A tag for Exif users to write keywords or comments on the image " "besides those in , and without the " "character code limitations of the tag."), - exifId, userInfo, comment, 0, printComment), + exifId, userInfo, comment, 0, printValue), TagInfo(0x9290, "SubSecTime", N_("Sub-seconds Time"), N_("A tag used to record fractions of seconds for the tag."), exifId, dateTime, asciiString, 0, printValue), @@ -2204,11 +2204,11 @@ namespace Exiv2 { TagInfo(0x001b, "GPSProcessingMethod", N_("GPS Processing Method"), N_("A character string recording the name of the method used for location finding. " "The string encoding is defined using the same scheme as UserComment."), - gpsId, gpsTags, comment, 0, printComment), + gpsId, gpsTags, comment, 0, printValue), TagInfo(0x001c, "GPSAreaInformation", N_("GPS Area Information"), N_("A character string recording the name of the GPS area." "The string encoding is defined using the same scheme as UserComment."), - gpsId, gpsTags, comment, 0, printComment), + gpsId, gpsTags, comment, 0, printValue), TagInfo(0x001d, "GPSDateStamp", N_("GPS Date Stamp"), N_("A character string recording date and time information relative to UTC " "(Coordinated Universal Time). The format is \"YYYY:MM:DD.\"."), @@ -2461,17 +2461,6 @@ namespace Exiv2 { return os << value; } - std::ostream& printComment(std::ostream& os, const Value& value, const ExifData*) - { - const Exiv2::CommentValue* cv = dynamic_cast(&value); - Exiv2::CommentValue::CharsetId csId = cv->charsetId(); - if ( csId != CommentValue::undefined ) { - os << "charset=" << CommentValue::CharsetInfo::name(csId) << " "; - } - os << cv->comment(); - return os ; - } - std::ostream& printBitmask(std::ostream& os, const Value& value, const ExifData* metadata) { if (value.typeId() == Exiv2::unsignedShort || value.typeId() == Exiv2::signedShort) diff --git a/src/tags_int.hpp b/src/tags_int.hpp index cbd22c4f19..694624cc11 100644 --- a/src/tags_int.hpp +++ b/src/tags_int.hpp @@ -362,8 +362,6 @@ namespace Exiv2 { //@{ //! Default print function, using the Value output operator std::ostream& printValue(std::ostream& os, const Value& value, const ExifData*); - //! Print the value of a comment - std::ostream& printComment(std::ostream& os, const Value& value, const ExifData*); //! Print the value converted to a long std::ostream& printLong(std::ostream& os, const Value& value, const ExifData*); //! Print a Rational or URational value in floating point format diff --git a/test/data/exifdata-test.out b/test/data/exifdata-test.out index 1cc1479cad..2605f0e23b 100644 --- a/test/data/exifdata-test.out +++ b/test/data/exifdata-test.out @@ -819,7 +819,7 @@ Exif.NikonFl1.0x0011 0x0011 Makernote Byte 3 Exif.Nikon3.ImageOptimization 0x00a9 Makernote Ascii 16 NORMAL Exif.Nikon3.Saturation 0x00aa Makernote Ascii 16 NORMAL Exif.Nikon3.VariProgram 0x00ab Makernote Ascii 16 -Exif.Photo.UserComment 0x9286 Exif Undefined 44 +Exif.Photo.UserComment 0x9286 Exif Undefined 44 charset=Ascii Exif.Photo.SubSecTime 0x9290 Exif Ascii 3 00 Exif.Photo.SubSecTimeOriginal 0x9291 Exif Ascii 3 00 Exif.Photo.SubSecTimeDigitized 0x9292 Exif Ascii 3 00 @@ -990,7 +990,7 @@ Exif.NikonFl1.0x0011 0x0011 Makernote Byte 3 Exif.Nikon3.ImageOptimization 0x00a9 Makernote Ascii 16 NORMAL Exif.Nikon3.Saturation 0x00aa Makernote Ascii 16 NORMAL Exif.Nikon3.VariProgram 0x00ab Makernote Ascii 16 -Exif.Photo.UserComment 0x9286 Exif Undefined 44 +Exif.Photo.UserComment 0x9286 Exif Undefined 44 charset=Ascii Exif.Photo.SubSecTime 0x9290 Exif Ascii 3 00 Exif.Photo.SubSecTimeOriginal 0x9291 Exif Ascii 3 00 Exif.Photo.SubSecTimeDigitized 0x9292 Exif Ascii 3 00 @@ -1162,7 +1162,7 @@ Exif.NikonFl1.0x0011 0x0011 Makernote Byte 3 Exif.Nikon3.ImageOptimization 0x00a9 Makernote Ascii 16 NORMAL Exif.Nikon3.Saturation 0x00aa Makernote Ascii 16 NORMAL Exif.Nikon3.VariProgram 0x00ab Makernote Ascii 16 -Exif.Photo.UserComment 0x9286 Exif Undefined 44 +Exif.Photo.UserComment 0x9286 Exif Undefined 44 charset=Ascii Exif.Photo.SubSecTime 0x9290 Exif Ascii 3 00 Exif.Photo.SubSecTimeOriginal 0x9291 Exif Ascii 3 00 Exif.Photo.SubSecTimeDigitized 0x9292 Exif Ascii 3 00 @@ -1334,7 +1334,7 @@ Exif.NikonFl1.0x0011 0x0011 Makernote Byte 3 Exif.Nikon3.ImageOptimization 0x00a9 Makernote Ascii 16 NORMAL Exif.Nikon3.Saturation 0x00aa Makernote Ascii 16 NORMAL Exif.Nikon3.VariProgram 0x00ab Makernote Ascii 16 -Exif.Photo.UserComment 0x9286 Exif Undefined 44 +Exif.Photo.UserComment 0x9286 Exif Undefined 44 charset=Ascii Exif.Photo.SubSecTime 0x9290 Exif Ascii 3 00 Exif.Photo.SubSecTimeOriginal 0x9291 Exif Ascii 3 00 Exif.Photo.SubSecTimeDigitized 0x9292 Exif Ascii 3 00 From 286641532229c7480761c8ad9f8a7ac1d7959321 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Mon, 14 Dec 2020 20:01:17 +0000 Subject: [PATCH 5/7] Revert "fix_1431_binary_comment." This reverts commit b6bf20a897091cc582d95c8aaa7e978cd01b96f2. --- src/value.cpp | 17 +++++++++++++++++ test/data/exiv2-bug528.jpg | Bin 10305 -> 10302 bytes tests/bugfixes/redmine/test_issue_528.py | 10 +++++----- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/value.cpp b/src/value.cpp index 9999782218..429ca1429d 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -551,6 +551,18 @@ namespace Exiv2 { return os << comment(); } + // test string for printable ascii-7 (' ' .. '~') + static bool isBinary(const std::string& s) + { + bool result = false ; + size_t i = 0; + while ( !result && i < s.length() ) { + unsigned char c = (unsigned char) s[i++]; + result = c < 32 || c > 127 ; + } + return result; + } + std::string CommentValue::comment(const char* encoding) const { std::string c; @@ -567,6 +579,11 @@ namespace Exiv2 { if ( bAscii && c.find('\0') != c.std::string::npos) { c = c.substr(0,c.find('\0')); } + // return "binary comment" if results contains non-printable bytes + // this ensures no binary bytes in the output stream. + if ( bAscii && isBinary(c) ) { + c = "binary comment" ; + } return c; } diff --git a/test/data/exiv2-bug528.jpg b/test/data/exiv2-bug528.jpg index 4921b4076722cafe30b57ff0a949a86e12a53981..cde81de25989a23fac62e7d3a0b4c032d216bf9e 100644 GIT binary patch delta 337 zcmX>YurFYOIOFDt65hPO83h=a7#JA%7#J8CCl-hs@-s>^umS}bfk>QDgMk^$1}b4R z1S{kQvg8?!z-$p9TWjJDeL=epRR$J_Cgx-Y2Ij95e<)6tV$`4P#i+=8q-ie9M5Z&7 zD;V`{uS{Tp>1TQ|k&%HNsFj70iJ4&%BLf%27^Xjym|(h?SthZ-#F=>}KVejs6q!^5 z)+GeAOlDFWn5_zA>rGZ*isubp#1GdSJ-LVJkgQ{{v!^G}Wao^;lGMb~3WbzZg`7kM zpZv_CRIbT6%(jMmfj$KV1d}U}0D1-#20*_vUj?#&VFAVr3~X?7-%h^89Lgxa*?>h* F1pxWVGQ$7> delta 302 zcmdlNa4=wkIODd765hOj7zG%Z7#JA%7#J9tCKiYr3NT7DumS}bfk=W;gMk^$1}b4R z1S{kQvJ@DNz-$p9TW8`9eL;r~RR$J_CgwB-2Ie0Ve<)6tU^JNQ&ZxwDtZ6RHM5c3- z%NX@-uT5Zq>1TR1k&%HNsFj70iJ4&%BLf%27^Z)dm|(h?*(R~T#F_afKVnpt6q{57 z)+GeAOm0#en5_n68%&mCisubm#1GdSH@S=H5XeIe43h(y#hG*zCTB9+N*(}u4CHSn gSC9+~SUJ$E%r_?QXBKDtF!?%jD5KJ5T^2zV0K1$l!~g&Q diff --git a/tests/bugfixes/redmine/test_issue_528.py b/tests/bugfixes/redmine/test_issue_528.py index b7ce0e8a2c..c17c49bbd4 100644 --- a/tests/bugfixes/redmine/test_issue_528.py +++ b/tests/bugfixes/redmine/test_issue_528.py @@ -30,7 +30,7 @@ class TypeSizeForExifOnly(metaclass=system_tests.CaseMeta): Exif.Image.YCbCrPositioning Short 1 Centered Exif.Image.Rating SLong 1 3 Exif.Image.RatingPercent SLong 1 50 -Exif.Image.ExifTag Long 1 320 +Exif.Image.ExifTag Long 1 318 Exif.Photo.ExposureTime Rational 1 1/250 s Exif.Photo.FNumber Rational 1 F11 Exif.Photo.ExposureProgram Short 1 Auto @@ -46,10 +46,10 @@ class TypeSizeForExifOnly(metaclass=system_tests.CaseMeta): Exif.Photo.Flash Short 1 No, compulsory Exif.Photo.FocalLength Rational 1 10.0 mm Exif.Photo.MakerNote Undefined 18 0 1 2 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 -Exif.MakerNote.Offset Long 1 798 +Exif.MakerNote.Offset Long 1 796 Exif.MakerNote.ByteOrder Ascii 3 MM Exif.Canon.0x0200 0x0300 0 -Exif.Photo.UserComment Undefined 38 Chateaux de la Loire, Chambord +Exif.Photo.UserComment Undefined 37 charset=Ascii binary comment Exif.Photo.SubSecTime Ascii 3 81 Exif.Photo.SubSecTimeOriginal Ascii 3 81 Exif.Photo.SubSecTimeDigitized Ascii 3 81 @@ -66,7 +66,7 @@ class TypeSizeForExifOnly(metaclass=system_tests.CaseMeta): Exif.Photo.SceneCaptureType Short 1 Standard Exif.Photo.Contrast Short 1 Normal Exif.Photo.Saturation Short 1 Normal -Exif.Image.GPSTag Long 1 870 +Exif.Image.GPSTag Long 1 867 Exif.GPSInfo.GPSVersionID Byte 4 2.0.0.0 Exif.GPSInfo.GPSLatitudeRef Ascii 2 North Exif.GPSInfo.GPSLatitude Rational 3 47deg 36' 58" @@ -75,7 +75,7 @@ class TypeSizeForExifOnly(metaclass=system_tests.CaseMeta): Exif.GPSInfo.GPSAltitudeRef Byte 1 Above sea level Exif.GPSInfo.GPSAltitude Rational 1 86 m Exif.Thumbnail.Compression Short 1 JPEG (old-style) -Exif.Thumbnail.JPEGInterchangeFormat Long 1 1058 +Exif.Thumbnail.JPEGInterchangeFormat Long 1 1055 Exif.Thumbnail.JPEGInterchangeFormatLength Long 1 4492 """, """File 1/1: $filename From c6167258ce61722eefc40cf95e5580fa720fcb09 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Mon, 14 Dec 2020 20:15:42 +0000 Subject: [PATCH 6/7] Revert "Restored 0.27.2 "toString()" behaviour of Exifdatum.value().toString() for CommentValue." This reverts commit ecae9dc6eba437d9ef568e3b3b377932ff76f309. --- src/exif.cpp | 12 ++---------- src/value.cpp | 4 ++++ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/exif.cpp b/src/exif.cpp index 78c8ae0837..493fd20b92 100644 --- a/src/exif.cpp +++ b/src/exif.cpp @@ -226,16 +226,8 @@ namespace Exiv2 { if ( ti ) { fct = ti->printFct_; if ( ti->typeId_ == comment ) { - fct=NULL; - const Exiv2::CommentValue* cv = dynamic_cast(&value()); - Exiv2::CommentValue::CharsetId csId = cv->charsetId(); - if ( csId != CommentValue::undefined ) { - os << "charset=" << CommentValue::CharsetInfo::name(csId) << " "; - } - os << cv->comment(); -#if 0 - os << "|| value().toString() = " << value().toString(); -#endif + os << value().toString(); + fct=NULL; } } if ( fct ) fct(os, value(), pMetadata); diff --git a/src/value.cpp b/src/value.cpp index 429ca1429d..5bd815e2e7 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -548,6 +548,10 @@ namespace Exiv2 { std::ostream& CommentValue::write(std::ostream& os) const { + CharsetId csId = charsetId(); + if (csId != undefined) { + os << "charset=" << CharsetInfo::name(csId) << " "; + } return os << comment(); } From 9b5108583b1acb93677790e959592ef7297f6b58 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Mon, 14 Dec 2020 20:29:27 +0000 Subject: [PATCH 7/7] Revert "Revert "fix_1431_binary_comment."" This reverts commit 286641532229c7480761c8ad9f8a7ac1d7959321. --- src/value.cpp | 17 ----------------- test/data/exiv2-bug528.jpg | Bin 10302 -> 10305 bytes tests/bugfixes/redmine/test_issue_528.py | 10 +++++----- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/src/value.cpp b/src/value.cpp index 5bd815e2e7..b96f7de350 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -555,18 +555,6 @@ namespace Exiv2 { return os << comment(); } - // test string for printable ascii-7 (' ' .. '~') - static bool isBinary(const std::string& s) - { - bool result = false ; - size_t i = 0; - while ( !result && i < s.length() ) { - unsigned char c = (unsigned char) s[i++]; - result = c < 32 || c > 127 ; - } - return result; - } - std::string CommentValue::comment(const char* encoding) const { std::string c; @@ -583,11 +571,6 @@ namespace Exiv2 { if ( bAscii && c.find('\0') != c.std::string::npos) { c = c.substr(0,c.find('\0')); } - // return "binary comment" if results contains non-printable bytes - // this ensures no binary bytes in the output stream. - if ( bAscii && isBinary(c) ) { - c = "binary comment" ; - } return c; } diff --git a/test/data/exiv2-bug528.jpg b/test/data/exiv2-bug528.jpg index cde81de25989a23fac62e7d3a0b4c032d216bf9e..4921b4076722cafe30b57ff0a949a86e12a53981 100644 GIT binary patch delta 302 zcmdlNa4=wkIODd765hOj7zG%Z7#JA%7#J9tCKiYr3NT7DumS}bfk=W;gMk^$1}b4R z1S{kQvJ@DNz-$p9TW8`9eL;r~RR$J_CgwB-2Ie0Ve<)6tU^JNQ&ZxwDtZ6RHM5c3- z%NX@-uT5Zq>1TR1k&%HNsFj70iJ4&%BLf%27^Z)dm|(h?*(R~T#F_afKVnpt6q{57 z)+GeAOm0#en5_n68%&mCisubm#1GdSH@S=H5XeIe43h(y#hG*zCTB9+N*(}u4CHSn gSC9+~SUJ$E%r_?QXBKDtF!?%jD5KJ5T^2zV0K1$l!~g&Q delta 337 zcmX>YurFYOIOFDt65hPO83h=a7#JA%7#J8CCl-hs@-s>^umS}bfk>QDgMk^$1}b4R z1S{kQvg8?!z-$p9TWjJDeL=epRR$J_Cgx-Y2Ij95e<)6tV$`4P#i+=8q-ie9M5Z&7 zD;V`{uS{Tp>1TQ|k&%HNsFj70iJ4&%BLf%27^Xjym|(h?SthZ-#F=>}KVejs6q!^5 z)+GeAOlDFWn5_zA>rGZ*isubp#1GdSJ-LVJkgQ{{v!^G}Wao^;lGMb~3WbzZg`7kM zpZv_CRIbT6%(jMmfj$KV1d}U}0D1-#20*_vUj?#&VFAVr3~X?7-%h^89Lgxa*?>h* F1pxWVGQ$7> diff --git a/tests/bugfixes/redmine/test_issue_528.py b/tests/bugfixes/redmine/test_issue_528.py index c17c49bbd4..b7ce0e8a2c 100644 --- a/tests/bugfixes/redmine/test_issue_528.py +++ b/tests/bugfixes/redmine/test_issue_528.py @@ -30,7 +30,7 @@ class TypeSizeForExifOnly(metaclass=system_tests.CaseMeta): Exif.Image.YCbCrPositioning Short 1 Centered Exif.Image.Rating SLong 1 3 Exif.Image.RatingPercent SLong 1 50 -Exif.Image.ExifTag Long 1 318 +Exif.Image.ExifTag Long 1 320 Exif.Photo.ExposureTime Rational 1 1/250 s Exif.Photo.FNumber Rational 1 F11 Exif.Photo.ExposureProgram Short 1 Auto @@ -46,10 +46,10 @@ class TypeSizeForExifOnly(metaclass=system_tests.CaseMeta): Exif.Photo.Flash Short 1 No, compulsory Exif.Photo.FocalLength Rational 1 10.0 mm Exif.Photo.MakerNote Undefined 18 0 1 2 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 -Exif.MakerNote.Offset Long 1 796 +Exif.MakerNote.Offset Long 1 798 Exif.MakerNote.ByteOrder Ascii 3 MM Exif.Canon.0x0200 0x0300 0 -Exif.Photo.UserComment Undefined 37 charset=Ascii binary comment +Exif.Photo.UserComment Undefined 38 Chateaux de la Loire, Chambord Exif.Photo.SubSecTime Ascii 3 81 Exif.Photo.SubSecTimeOriginal Ascii 3 81 Exif.Photo.SubSecTimeDigitized Ascii 3 81 @@ -66,7 +66,7 @@ class TypeSizeForExifOnly(metaclass=system_tests.CaseMeta): Exif.Photo.SceneCaptureType Short 1 Standard Exif.Photo.Contrast Short 1 Normal Exif.Photo.Saturation Short 1 Normal -Exif.Image.GPSTag Long 1 867 +Exif.Image.GPSTag Long 1 870 Exif.GPSInfo.GPSVersionID Byte 4 2.0.0.0 Exif.GPSInfo.GPSLatitudeRef Ascii 2 North Exif.GPSInfo.GPSLatitude Rational 3 47deg 36' 58" @@ -75,7 +75,7 @@ class TypeSizeForExifOnly(metaclass=system_tests.CaseMeta): Exif.GPSInfo.GPSAltitudeRef Byte 1 Above sea level Exif.GPSInfo.GPSAltitude Rational 1 86 m Exif.Thumbnail.Compression Short 1 JPEG (old-style) -Exif.Thumbnail.JPEGInterchangeFormat Long 1 1055 +Exif.Thumbnail.JPEGInterchangeFormat Long 1 1058 Exif.Thumbnail.JPEGInterchangeFormatLength Long 1 4492 """, """File 1/1: $filename