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 725397 - assertion failure from malformed input
assertion failure from malformed input
Status: RESOLVED OBSOLETE
Product: json-glib
Classification: Core
Component: Parser
git master
Other Linux
: Normal normal
: ---
Assigned To: json-glib-maint
json-glib-maint
Depends on: 725507
Blocks:
 
 
Reported: 2014-02-28 13:14 UTC by Tim Waugh
Modified: 2017-09-05 10:40 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Tim Waugh 2014-02-28 13:14:04 UTC
json-glib fails with an assertion failure with some types of malformed JSON inputs.

See bug #723368 comment #17 for an example of this:
  https://bugzilla.gnome.org/show_bug.cgi?id=723368#c17

This is unfortunate because the JSON input comes from a REST response and is not under our control. A GError response would be much better: applications shouldn't crash when a server gives an expected response.

This particular case came about because the Google Cloud Print service responds to a POST /submit request with a JSON object containing the entire response, including "content" (the contents of a PDF file) as a string.
Comment 1 Emmanuele Bassi (:ebassi) 2014-02-28 13:24:32 UTC
JsonParser should never crash; malformed JSON should just give a JSON_PARSER_ERROR.

in the bug you linked you're tripping an assertion in the underlying tokenizer. it seems the source is violating the JSON spec as well.

to be fair, you should ask the server to fix their JSON: it's utterly broken, and you cannot know how any other JSON parser will behave when it comes to broken Unicode surrogate pairs. brokenness of input begets undefined behaviour.

in any case, I can probably replace the assert() with a scanner error, which would be raised up to the JsonParser.
Comment 2 Emmanuele Bassi (:ebassi) 2014-03-02 16:34:59 UTC
it turns out that some stuff in JsonScanner (our internal fork of GScanner) simply cannot be reported as errors: we have assertions all over the place, and even if we just ignored malformed data we would not be able to get a GError in place for caller code to handle.

this will have to wait once we have a new tokenizer in place.

I'm marking this bug as being blocked by bug 725507.
Comment 3 Emmanuele Bassi (:ebassi) 2017-09-05 10:40:23 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/json-glib/issues/10.