-
Notifications
You must be signed in to change notification settings - Fork 332
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
Escape closing tags in strings #51
Conversation
+1 for this patch. If nothing else would be great to somehow include it in the Rails compatibility mode because the Rails implementation avoids this issue by unicode escaping the ">". |
This should fix issue ruby#51 on Windows
RFC JSON doesn't allow such extra escape. This patch should be rejected. Anyway as Rails does, using Unicode escape like str.gsub(/</(script)>/i, "<\u002F\1>") is not bad. |
I don't see what's not allowed. As the spec says, "Any character may be escaped" (save for the 3 exceptions mentioned a paragraph before, which must be escaped), and the " |
Ah, yes / is collect sorry
|
+1 Hoping to see this patch pulled in soon! |
This should be closed in favor of #405 |
@hsbt could you please close this? |
About the proposed patch: replacing the precise instances of "</script>" via a post-generation scan (like a
foo.gsub!("</script>", '<\/script>')
) would pretty much defeat the speed purposes of this gem (on the ext/jruby side), and replacing these instances mid-generation (through a look-ahead, for instance) would complicate the code too much. On the other hand, replacing every single "/" character with a "/" sequence could make certain strings needlessly less readable (for instance, URLs starting with "http://"). So, I think the compromise of replacing all "</" sequences with "</" offers the best combination of code simplicity and JSON readability. This patch implements this approach on all 3 versions (pure, ext, jruby) and adds a new test.