Skip to main content

Bug Tracker

Side navigation

#8034 closed bug (invalid)

Opened January 21, 2011 09:12PM UTC

Closed January 21, 2011 10:29PM UTC

Last modified March 10, 2012 06:43AM UTC

parseJSON() fails when special characters are passed in

Reported by: ievolve Owned by: rwaldron
Priority: low Milestone:
Component: core Version: 1.4.2
Keywords: Cc:
Blocked by: Blocking:

I came across a situation where some oddly encoded characters cause the JSON parser to bomb. In my case it was the cancel character (0x18) that a user had submitted.

Worth noting that JSON parse that is at the link below will parse things just fine. Where JSON.parse() bombs just like the jQuery method.

Code that contains the cancel character can be copied and pasted from here to relicate the issue. The bad character sits between the n and the s in the word "brains"

Attachments (0)
Change History (4)

Changed January 21, 2011 09:19PM UTC by ievolve comment:1

_comment0: To see this bug in action see the example here:

To see this bug in action see the example here:

Should note that the bug also occurs in 1.4.4 as well

Changed January 21, 2011 09:20PM UTC by rwaldron comment:2

component: unfiledcore
owner: → rwaldron
status: newassigned

Changed January 21, 2011 10:06PM UTC by rwaldron comment:3

We can test for these...

Changed January 21, 2011 10:29PM UTC by jitter comment:4

priority: undecidedlow
resolution: → invalid
status: assignedclosed

This isn't a bug, the JSON specification is clear about which characters need to be escaped in valid json.

2.5. Strings\\\\ [...]\\\\ All Unicode characters may be placed within the quotation marks except for the characters that must be escaped: quotation mark, reverse solidus, and the control characters (U+0000 through U+001F).

As U+0018 lies in this range, throwing an exception is the specified behavior of jQuery.parseJSON.

Running your sample json through the JSON validator also reveals that this is invalid json.