-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
JSONObject::quote(). Why special case for "</" but not "/" #26
Comments
There is no requirement to escape /, but it may be escaped. This is useful when embedding JSON in HTML. |
I thought the grammar: http://json.org/ required it to be escaped. It's in the same list and no different from \b, \t, , etc. I'm worried about parser interoperability between different platforms like Java generated JSON on C++... |
You are mistaken. |
No he is right. JsonObject DOES quote forward slashes in |
@Doogiemuc the forward slash escape is technically optional in the JSON spec, which is what Douglas was talking about. The reason that this library escapes them is because embedding JSON directly into HTML can cause "remote code execution" issues when you don't escape them. We escape them by default for safety, not because it's required by the spec. For more information see: https://stackoverflow.com/questions/1580647/json-why-are-forward-slashes-escaped#1580682 |
Fixes NPE in XML for pull request stleary#160 in the json-java project
Hi,
I'm having trouble understanding this code:
case '/':
if (b == '<') {
sb.append('');
}
sb.append(c);
break;
Why is escape character '' only appended when the previous character is <. Looking at JSON control characters, the '/' is always a control character and should be prefixed with . Yet the code doesn't do that.
Thanks,
The text was updated successfully, but these errors were encountered: