-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
proposal: x/net/html: add RawNode #36350
Comments
/cc @nigeltao @namusyaka |
I'm not keen on using |
We have reasons why html/template is not appropriate because it is made to render HTML securely, why we need to render HTML that has already been made secure by the underlying libraries (ie. react-dom, etc). Also, ideally we'd like to keep source files as generated automatically and not have to build specific versions for Right now the way we render things is (for example): div.AppendChild(&html.Node{
Type: html.CommentNode,
Data: " begin app -->" + app + "<!-- end app ",
}) This works fine, but I feel implementing a |
Change https://golang.org/cl/216800 mentions this issue: |
I was concerned about security implications, but you're right that we can already render arbitrary (insecure) HTML with a CommentNode. Let's do this: https://golang.org/cl/216800 |
html raw nodes
Sometimes there is a need after parsing HTML to insert more html contents without having to parse the added contents (for example, server side rendering of HTML code).
It should be fairly simple to add the following to x/net/html:
(I looked at submitting a pull request, but it's just too much hassle going through gerrit for 4 lines of code)
current situation
Right now the easiest way to add raw html is through a CommentNode by including tags to end and resume comment, but this is not optimal. Adding a RawNode NodeType wouldn't have any negative impact and would allow adding raw html prior to rendering of contents for cases when HTML is obtained as is and doesn't need to be parsed.
The text was updated successfully, but these errors were encountered: