-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSONP renderer fails to escape U+2028 and U+2029 #2169
Comments
Which version of python is this btw? |
Should this additionally be added as a Python bug. Appears to be resolved in simplejson - https://github.com/simplejson/simplejson/blob/master/simplejson/encoder.py#L36 And I don't see it listed as an issue?... http://bugs.python.org/issue?%40columns=id%2Cactivity%2Ctitle%2Ccreator%2Cassignee%2Cstatus%2Ctype&%40sort=-activity&%40filter=status&%40action=searchid&ignore=file%3Acontent&%40search_text=2028+2029+json&submit=search&status=-1%2C1%2C2%2C3 |
I run Python 2.7.3. This may be a nice thing to have in the standard |
So unsure whether to resolve this in JSONRenderer (as an enhancement) or in JSONPRenderer (as a bugfix). Aside: Personally I do still class this as a bug in the Python json lib, as there's no good reason why it should just always be escaped. The JSON spec clearly has a bug when it refers to being derived from "a small subset of ECMAScript" http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf Unclear why they don't at least add an ammendment recommending that implementations escape those two characters. |
While I agree that it's an oversight in the JSON specification, I'm leaning towards it being an issue in It may be useful to open a ticket to see if the CPython |
It's resolved in rails, it's resolved in simplejson, not super impressed that the python ticket is classed as 'not a bug'. Disagree with that assessment. |
Maybe we could make simplejson easy to use instead of the default json. |
It's an option, although not strictly necessary to the resolution of this ticket, and would mean users have one extra thing to think about (rather than we just deal with it quietly) |
When Unicode is enabled for JSON output, the JSONP renderer fails to escape U+2028 and U+2029 which are valid in JSON but invalid in JavaScript.
Try adding this simple model to the example app from the README:
Create an object like this:
Then fire up a dev server and make an HTML page with a JSONP request like this:
Open the page in your browser and observe the error console. In Chromium, I get:
The text was updated successfully, but these errors were encountered: