ExifTool Forum

ExifTool => Bug Reports / Feature Requests => Topic started by: jst on January 23, 2018, 04:52:44 AM

Title: JSON: \u0000 in ICC_Profile:CharTarget
Post by: jst on January 23, 2018, 04:52:44 AM
I run ExifTool on Linux.
The tag ICC_Profile:CharTarget in the JSON-output containes a trailing \u0000.
It looks like it should not be part of the value.

This problem occurs with the attached image.
exiftool -j -G -ICC_Profile:CharTarget image.jpg

The attached diff for Version 10.76 fixed this for me.
patch lib/Image/ExifTool/ICC_Profile.pm patch.diff

Quote9.2.14 charTargetTag
...
If the first seven characters are "ICCHDAT", then the remainder of the text shall be a single space followed by
the Reference Name of a characterization data set in the Characterization Data Registry maintained by ICC,
and terminated with a NULL byte (00h). ...
http://www.color.org/specification/ICC1v43_2010-12.pdf (http://www.color.org/specification/ICC1v43_2010-12.pdf)
Title: Re: JSON: \u0000 in ICC_Profile:CharTarget
Post by: Phil Harvey on January 23, 2018, 07:08:02 AM
Great, thanks for this patch!

- Phil
Title: Re: JSON: \u0000 in ICC_Profile:CharTarget
Post by: jst on February 01, 2018, 09:08:44 AM
I noticed that ICC_Profile:CharTarget is not the only tag with a \u0000 problem.

1)
Most \u0000 are trailing in JSON-strings. (e.g. "ABC\u0000\u0000\u0000\u0000").

I added $str =~ s/\0+$//mg to EscapeJSON().
I am not sure if this is the right way, but it is most likely that many JSON-Parser and String-Implementations cannot handle the NULL character, because this indicates the end of a string.

2)
\0+ seems to be the end of a ListEntry for IPTC:DocumentHistory.
Every entry is padded with \0  to 256 characters.
I added ValueConv => '$val =~ s/\0+/\n/g; $val'.
Maybe here is a better way too.

Unfortunately, I am not able to execute exiftool -tagsfromfile f1.jpg -EXIF:UserComment -IPTC:DocumentHistory f2.jpg successfully.
ExifTool prints "Warning: Can't convert value for IPTC:DocumentHistory (no ValueConvInv)" and "Invalid EXIF text encoding for UserComment".
Is there a way to copy invalid tags, so I can upload examples. (I do not want to upload the original files.)
Title: Re: JSON: \u0000 in ICC_Profile:CharTarget
Post by: Phil Harvey on February 01, 2018, 10:20:11 AM
How about the attached patch to remove nulls from the JSON output?

- Phil

Edit:  Oh.  I see that you have done a similar thing already (your point number 1).

You can add "ValueConvInv => '$val'," to get rid of the "No ValueConvInv" warning.

For examples, you can copy the entire IPTC or EXIF block containing the questionable information (with -iptc or -exif).
Title: Re: JSON: \u0000 in ICC_Profile:CharTarget
Post by: jst on February 01, 2018, 10:49:31 AM
Is the else-branch really required?
The function returns in the if-branch.
Title: Re: JSON: \u0000 in ICC_Profile:CharTarget
Post by: Phil Harvey on February 01, 2018, 10:54:18 AM
You're right.  The "else" isn't necessary.
Title: Re: JSON: \u0000 in ICC_Profile:CharTarget
Post by: jst on February 01, 2018, 11:47:37 AM
I managed to create an example picture for point number 2. (See Attachments)
Title: Re: JSON: \u0000 in ICC_Profile:CharTarget
Post by: Phil Harvey on February 01, 2018, 03:14:05 PM
OK, thanks.  I'll apply your patch to deal with this.

- Phil
Title: Re: JSON: \u0000 in ICC_Profile:CharTarget
Post by: jst on February 13, 2018, 03:56:40 AM
When is the next release version, containing this patches, planned?
Title: Re: JSON: \u0000 in ICC_Profile:CharTarget
Post by: Phil Harvey on February 13, 2018, 07:25:21 AM
It was released on Sunday.

- Phil
Title: Re: JSON: \u0000 in ICC_Profile:CharTarget
Post by: jst on February 13, 2018, 07:40:11 AM
Sorry, I wanted to write production release version.
Is there a date for this?
Title: Re: JSON: \u0000 in ICC_Profile:CharTarget
Post by: Phil Harvey on February 13, 2018, 07:41:29 AM
Probably in about a week or so.

- Phil