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

Unnecessary encoding of element text content #3879

Closed
mikecardwell opened this issue May 14, 2015 · 4 comments
Closed

Unnecessary encoding of element text content #3879

mikecardwell opened this issue May 14, 2015 · 4 comments

Comments

@mikecardwell
Copy link

Given the following piece of code:

let some_text = 'Hello"<>&\'World';
React.render(<div>{some_text}</div>, somewhere);

React replaces the angle brackets, quotation mark, apostrophe and ampersands with their HTML entities, ie &lt; &gt; &quot; &amp; etc. I don't believe it is necessary to replace the quotation mark or the apostrophe. They don't need escaping. They would only need escaping when used in an attribute, not when used as the text content of an element.

The reason I noticed this is because I'm trying to encode some JSON into a HTML element on the server side which can then be read back by the client side javascript. JSON contains a lot of double quotation marks and they're all being needlessly replaced by &quot;'s

@mikecardwell
Copy link
Author

I've just taken a look at the React code for the first time. It's very readable. I can provide a fix for this if you agree it needs fixing.

@zpao
Copy link
Member

zpao commented May 14, 2015

There's a bunch of discussion about this in #3152. Let's continue there, might be a good time to revisit and make it actually happen. I'm not an expert about this so definitely value more expert opinions!

@gaearon
Copy link
Collaborator

gaearon commented Mar 26, 2016

As part of the effort to move discussion of intent to issues and close stale PRs, I closed #3152 which did not get merged, and reopened this issue. If this is something we want to fix, let’s discuss it here, and reach consensus first.

@necolas
Copy link
Contributor

necolas commented Oct 15, 2019

This issue hasn't seen much activity or interest over the last 3 years so I'm closing it

@necolas necolas closed this as completed Oct 15, 2019
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

4 participants