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

add escapes suitable for HTML embedding #320

Open
clarkevans opened this issue Apr 24, 2021 · 0 comments
Open

add escapes suitable for HTML embedding #320

clarkevans opened this issue Apr 24, 2021 · 0 comments

Comments

@clarkevans
Copy link

clarkevans commented Apr 24, 2021

Often, I've seen JSON used to encode content so that it could be included in a <script tag within Pluto.jl notebooks. However, within a HTML <script> tag, additional escaping is needed:

The easiest and safest way to avoid the rather strange restrictions described in this section is to always escape an ASCII case-insensitive match for "<!--" as "<\!--", "<script" as "<\script", and "</script" as "<\/script" when these sequences appear in literals in scripts (e.g. in strings, regular expressions, or comments), and to avoid writing code that uses such constructs in expressions.

The issue here is that JSON doesn't like \\!, \\s, and \\S, so I suppose one would have to use the equivalent unicode escape sequences: "<!" as "<\\u0021", "<s" as "<\\u0073", "<S" as "<\\u0053", and "</" as "<\\/".

It'd be perhaps useful to additionally escape these sequences. It won't hurt normal JSON encodings, but would make JSON safe for making Javascript content to be embedded in HTML.

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

No branches or pull requests

1 participant