Merge pull request #2133 from Exiv2/fix_2126_xml_term

Strip XMP raw packet before decoding
This commit is contained in:
Miloš Komarčević 2022-03-10 13:16:40 +01:00 committed by GitHub
commit 1e2b9daf3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 6 deletions

View File

@ -753,8 +753,12 @@ namespace Exiv2 {
return 2;
}
XMLValidator::check(xmpPacket.data(), xmpPacket.size());
SXMPMeta meta(xmpPacket.data(), static_cast<XMP_StringLen>(xmpPacket.size()));
// Make sure the unterminated substring is used
size_t len = xmpPacket.size();
while (len > 0 && 0 == xmpPacket[len - 1]) --len;
XMLValidator::check(xmpPacket.data(), len);
SXMPMeta meta(xmpPacket.data(), static_cast<XMP_StringLen>(len));
SXMPIterator iter(meta);
std::string schemaNs, propPath, propValue;
XMP_OptionBits opt = 0;

View File

@ -1,5 +1,3 @@
Error: XMP Toolkit error 201: Error in XMLValidator
Warning: Failed to decode XMP metadata.
Exif.Image.Make Ascii 6 Canon Canon
Exif.Image.Model Ascii 22 Canon PowerShot S5 IS Canon PowerShot S5 IS
Exif.Image.Orientation Short 1 1 top, left
@ -43,3 +41,11 @@ Iptc.Application2.DigitizationTime Time 11 09:54:34+00:00 09:5
Iptc.Application2.DigitizationDate Date 8 2008-05-08 2008-05-08
Iptc.Application2.DateCreated Date 8 2008-05-08 2008-05-08
Iptc.Application2.TimeCreated Time 11 09:54:34+00:00 09:54:34+00:00
Xmp.aux.LensInfo XmpText 16 6/1 72/1 0/0 0/0 6/1 72/1 0/0 0/0
Xmp.aux.Lens XmpText 11 6.0-72.0mm 6.0-72.0mm
Xmp.aux.FlashCompensation XmpText 3 0/1 0/1
Xmp.aux.Firmware XmpText 21 Firmware Version 1.01 Firmware Version 1.01
Xmp.aux.OwnerName XmpText 11 Robin Mills Robin Mills
Xmp.xmp.CreateDate XmpText 19 2008-05-08T09:54:34 2008-05-08T09:54:34
Xmp.xmp.ModifyDate XmpText 19 2008-05-08T09:54:34 2008-05-08T09:54:34
Xmp.photoshop.DateCreated XmpText 19 2008-05-08T09:54:34 2008-05-08T09:54:34

View File

@ -1,5 +1,3 @@
Error: XMP Toolkit error 201: Error in XMLValidator
Warning: Failed to decode XMP metadata.
Exif.Image.Make Ascii 6 Canon Canon
Exif.Image.Model Ascii 22 Canon PowerShot S5 IS Canon PowerShot S5 IS
Exif.Image.Orientation Short 1 1 top, left
@ -43,3 +41,11 @@ Iptc.Application2.DigitizationTime Time 11 09:54:41+00:00 09:5
Iptc.Application2.DigitizationDate Date 8 2008-05-08 2008-05-08
Iptc.Application2.DateCreated Date 8 2008-05-08 2008-05-08
Iptc.Application2.TimeCreated Time 11 09:54:41+00:00 09:54:41+00:00
Xmp.aux.LensInfo XmpText 16 6/1 72/1 0/0 0/0 6/1 72/1 0/0 0/0
Xmp.aux.Lens XmpText 11 6.0-72.0mm 6.0-72.0mm
Xmp.aux.FlashCompensation XmpText 3 0/1 0/1
Xmp.aux.Firmware XmpText 21 Firmware Version 1.01 Firmware Version 1.01
Xmp.aux.OwnerName XmpText 11 Robin Mills Robin Mills
Xmp.xmp.CreateDate XmpText 19 2008-05-08T09:54:41 2008-05-08T09:54:41
Xmp.xmp.ModifyDate XmpText 19 2008-05-08T09:54:41 2008-05-08T09:54:41
Xmp.photoshop.DateCreated XmpText 19 2008-05-08T09:54:41 2008-05-08T09:54:41