Skip to content
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

Deserializer too strict with string escapes??? #66

Closed
GoogleCodeExporter opened this issue Mar 19, 2015 · 2 comments
Closed

Deserializer too strict with string escapes??? #66

GoogleCodeExporter opened this issue Mar 19, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

The deserializer seems to be too strict (maybe not even compliant?) in
handling escapes in strings.

In particular, JSON feeds such as Twitter escape slashes in strings, and
gson complains of a syntax error on encountering them.

Although in theory only double-quotes, reverse solidusses (sp?), and
control characters need be escaped, the "official" JSON syntax at
http://www.json.org/ explicitly lists the slash as being acceptable when
escaped.

Ya, maybe JSON generators should not be escaping slashes. But in line with
a paraphrase of the Postel Principle ("Generate strictly, accept
leniently"). maybe gson should accept any character when escaped?

Just a thought, I could be wrong. Comments welcome and expected.

Jim Renkel

Original issue reported on code.google.com by james.re...@gmail.com on 22 Oct 2008 at 4:02

@GoogleCodeExporter
Copy link
Author

Appendix E of "JavaScript: The Good Parts" said that:

"JSON allows the / character to be escaped so that JSON can be embedded in HTML
<script> tags. HTML does not allow the sequence </ except to start the 
</script> tag.
JSON allows <\/, which produces the same result but does not confuse HTML."


The solidum characters are escaped in other popular scripting languages (e.g., 
PHP).
So I think gson should consider it seriously.

Original comment by william....@gmail.com on 29 Oct 2008 at 10:17

@GoogleCodeExporter
Copy link
Author

I agree this is a good idea. I have fixed this in r279 and also added a test. 
We will 
include it in our next release.

Original comment by inder123 on 29 Oct 2008 at 11:32

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant