Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xmp: parsing xml failed: XML syntax error on line 1: invalid UTF-8 #10

Open
mholt opened this issue Jan 8, 2023 · 0 comments
Open

xmp: parsing xml failed: XML syntax error on line 1: invalid UTF-8 #10

mholt opened this issue Jan 8, 2023 · 0 comments

Comments

@mholt
Copy link

mholt commented Jan 8, 2023

Turns out nearly every photo from my phone has XMP data with "invalid UTF-8" in the makernotes.

Here's a snippet as produced by fmt.Printf("%s", packet):

fHy6To/e/1t1j���BCwxNl3v65eE2aZb08J5YkZUvsmV7C7loOkw2EJaL7VTYXHMXd3Rb0lCUy1Auhoe8gbS9ZafzrjIOOCVjpmk3H2WeRAiUwdRFieMdt+S1VvDOobXxCg6Nk8f16tykfSdpwFUi0XVaeVTiLYF00p4FBUPJET6THkH8HM5ol

This input results in xmp: parsing xml failed: XML syntax error on line 1: invalid UTF-8 within d.Decode() when it calls the stdlib xml.Decoder.Decode().

Here's are the actual file bytes starting at the same offset as the snippet above. But you'll notice that after the ??? things seem to diverge. I'm not sure what is wrong here, I don't really know enough about encodings:

66  48  79  36  54  6F  2F  65  2F  31  74  31  6A  6A  6A  47  46  6A  77  76  72  70  6F  2B  35
73  4E  64  6E  67  42  75  6C  4D  33  48  2B  65  77  5A  4F  64  61  32  46  77  35  51  73  4A
39  6F  75  2F  4D  59  48  4D  31  43  79  57  6D  7A  47  5A  77  56  78  72  4D  68  4F  36  2B
70  51  7A  76  7A  4C  48  6C  53  36  FF  E1  0E  75  68  74  74  70  3A  2F  2F  6E  73  2E  61
64  6F  62  65  2E  63  6F  6D  2F  78  6D  70  2F  65  78  74  65  6E  73  69  6F  6E  2F  00  33
31  43  41  32  34  33  45  36  31  39  34  33  41  39  36  39  34  31  39  41  35  35  34  46  39
39  43  42  46  45  43  00  01  0D  DA  00  00  FF  B2  42  43  77  78  4E  6C  33  76  36  35  65
45  32  61  5A  62  30  38  4A  35  59  6B  5A  55  76  73  6D  56  37  43  37

The "invalid UTF-8" is apparently at the sequence of 6A 6A 6A on the first line there. Here's a screenshot of the file in my hex viewer:

image

In the hex viewer, it shows "j j j G F" for those bytes.

ExifTool and other XMP parsers handle things fine, so I'm sure this is technically valid. It's just that the Go XML parser doesn't like it. Do you know any way to fix it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant