Convert doesn't properly escape JSON output

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
edalquist
Posts: 4
Joined: 2015-06-22T08:06:57-07:00
Authentication code: 6789

Convert doesn't properly escape JSON output

Post by edalquist »

I'm using the following command to extract a metadata dump from images for later processing:
"convert IMAGEFILE -moments json:-"

I've found a few issues where the JSON output is invalid due to ImageMagick not escaping the property values correctly.

There is an example image and JSON output file here:
https://drive.google.com/folderview?id= ... sp=sharing
edalquist
Posts: 4
Joined: 2015-06-22T08:06:57-07:00
Authentication code: 6789

Re: Convert doesn't properly escape JSON output

Post by edalquist »

It looks like just adding a basic JSON string escaping into ./coders/json.c might fix the issue, I might see if I can fix it tonight.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Convert doesn't properly escape JSON output

Post by dlemstra »

Feel free to submit a pull request on github or post your patch here.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
edalquist
Posts: 4
Joined: 2015-06-22T08:06:57-07:00
Authentication code: 6789

Re: Convert doesn't properly escape JSON output

Post by edalquist »

Oh I had found the svn code, would https://github.com/ImageMagick/ImageMagick be the correct place to submit a patch?

C is not my strong suit but I figure adding a simple string escaping method in one file should be easy enough.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Convert doesn't properly escape JSON output

Post by dlemstra »

That is indeed our github page.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
edalquist
Posts: 4
Joined: 2015-06-22T08:06:57-07:00
Authentication code: 6789

Re: Convert doesn't properly escape JSON output

Post by edalquist »

Thanks for merging (a much better version of) the fix!
https://github.com/ImageMagick/ImageMagick/pull/14
Post Reply