Skip to content

Is there a way to do "best-effort" XMP metadata parsing? (to overcome invalid XML) #3068

Answered by clanmills
ribtoks asked this question in Q&A
Discussion options

You must be logged in to vote

@ribtoks The XML is invalid, so every XML parser (including xmllint) will barf. You can't forgive or trick it, you have to repair the XML code.

readMetadata() reads the raw XML from the file.

            // Read the rest of the segment.
            DataBuf buf(size);
            if (size > 0) {
                readOrThrow(*io_, buf.pData_ + 2, size - 2, kerFailedToReadImageData);
                memcpy(buf.pData_, sizebuf, 2);
            }

At that moment, buf.pData_ has something like this:

1012 rmills@rmillsm1:~/gnu/github/exiv2/0.27-maintenance $ exiv2 -pS https://clanmills.com/Stonehenge.jpg
STRUCTURE OF JPEG FILE: https://clanmills.com/Stonehenge.jpg
 address | marker       |  lengt…

Replies: 2 comments 14 replies

Comment options

You must be logged in to vote
9 replies
@clanmills
Comment options

@ribtoks
Comment options

@ribtoks
Comment options

@clanmills
Comment options

Answer selected by ribtoks
@ribtoks
Comment options

@clanmills
Comment options

Comment options

You must be logged in to vote
5 replies
@ribtoks
Comment options

@kevinbackhouse
Comment options

@clanmills
Comment options

@ribtoks
Comment options

@kevinbackhouse
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants