After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 730425 - control chars in strings are escaped incorrectly
control chars in strings are escaped incorrectly
Status: RESOLVED FIXED
Product: json-glib
Classification: Core
Component: Generator
0.16.x
Other Linux
: Normal normal
: ---
Assigned To: json-glib-maint
json-glib-maint
Depends on:
Blocks:
 
 
Reported: 2014-05-20 07:56 UTC by Marius Vollmer
Modified: 2014-05-21 13:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
generator: Escape the control characters correctly (3.52 KB, patch)
2014-05-20 08:49 UTC, Stef Walter
committed Details | Review
generator: Add tests for updated string escaping routine (2.24 KB, patch)
2014-05-21 10:16 UTC, Stef Walter
committed Details | Review

Description Marius Vollmer 2014-05-20 07:56:20 UTC
For a string containing a ESC character, say, JsonGenerator produces the output "\033".  This is not legal JSON, which only allows "\u001b".
Comment 1 Stef Walter 2014-05-20 08:47:43 UTC
Using g_strescape() is wrong in JsonGenerator. It does everything wrong except for \b \t \n \" \\ \r \f.
Comment 2 Stef Walter 2014-05-20 08:49:46 UTC
Created attachment 276827 [details] [review]
generator: Escape the control characters correctly

Escaping these as octals is out of the JSON spec completely,
so roll our own string encoder.
Comment 3 Emmanuele Bassi (:ebassi) 2014-05-20 10:41:19 UTC
Review of attachment 276827 [details] [review]:

thanks for looking into this; the patch looks good, but it would be great to have a proper unit for the Generator test suite as well.
Comment 4 Stef Walter 2014-05-21 10:16:11 UTC
Created attachment 276924 [details] [review]
generator: Add tests for updated string escaping routine
Comment 5 Stef Walter 2014-05-21 10:16:40 UTC
Comment on attachment 276827 [details] [review]
generator: Escape the control characters correctly

Attachment 276827 [details] pushed as f2ee9a7 - generator: Escape the control characters correctly
Comment 6 Emmanuele Bassi (:ebassi) 2014-05-21 12:18:35 UTC
Review of attachment 276924 [details] [review]:

looks great, thanks!
Comment 7 Stef Walter 2014-05-21 13:58:07 UTC
Attachment 276924 [details] pushed as 8bbc873 - generator: Add tests for updated string escaping routine