GNOME Bugzilla – Bug 455481
Metadata plug-in does not escape special characters
Last modified: 2007-08-29 19:38:24 UTC
Please describe the problem: When saving the XMP data block in the metadata plugin special characters such as < > are not escaped causing a badly formed XMP block to be saved in the jpeg file. Steps to reproduce: 1. 2. 3. Actual results: Expected results: Does this happen every time? Other information:
Created attachment 91532 [details] [review] Patch to escape special characters in xmp_encode.c
g_markup_escape_text() allocates memory that needs to be freed using g_free(). As far as I can see your patch leaks that memory.
I don't think that it is the right place to escape the special characters, because this should be done already when the XMP data is read and copied into the internal data structures. I just saw that it is not done when you use the PDB calls, but I would rather try to fix it there rather than in xmp_encode.c because doing it at this stage is basically too late already. I will try to fix this as soon as possible. Just out of curiosity, how did you get these special characters in the XMP block?
I had an oldish test file with <Creator> in the IPTC creator field. This at some point had been updated into the XMP block. Opening this and then saving led to unescaped characters in the save file. I only noticed from the error messages when re-opening the file.
(In reply to comment #4) > I had an oldish test file with <Creator> in the IPTC creator field. This at > some point had been updated into the XMP block. It would be nice if you could attach that test file (or its XMP block) to this bug report so that I can check if the solution that I would like to apply will work with your file.
Sorry about the delay, I've been on holiday. Attached belowia a jpeg file with the correctly escaped characters < and > symbols in the xmp packet. Saving as a new jpeg exhibits the problem.
Created attachment 93777 [details] JPEG file with escaped characters in xmp block
Thanks for the test file. After analyzing this problem a bit, I changed my mind and decided to escape the characters in the output as you initially suggested. I had to rewrite the patch because the result of g_markup_escape_text() must be freed, but the basic idea is the same. 2007-08-29 Raphaël Quinet <raphael@gimp.org> * plug-ins/metadata/xmp-encode.c (gen_property): escape the text values output in the XMP packet. Based on a bug report and patch by John Marshall. Fixes bug #455481. There is still an issue with this test file because the flash settings are not parsed and saved correctly, but that's for another bug report...