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

Escape HTML in the text content #38

Merged
merged 1 commit into from
Nov 20, 2017
Merged

Escape HTML in the text content #38

merged 1 commit into from
Nov 20, 2017

Conversation

rbelouin
Copy link
Contributor

An issue I've noticed recently:

const html = toHTML(h('div', '<p></p>'));
console.log(html);

// outputs: <div><p></p></div>

As you can see, the HTML characters of the text content of the div tag aren't escaped properly. This isn't consistent with snabbdom's behavior and this is a security flaw: if anyone is using this library in production to render pages, they might be vulnerable to XSS attacks.

Issue #36 seems to be related.

@zkochan
Copy link

zkochan commented Nov 19, 2017

Just a note, even though this was a bug on snabbdom-to-html end, this IS a breaking change. I know devs that were using it as a feature, passing raw html as text

@acstll
Copy link
Member

acstll commented Nov 19, 2017

Thank you @rbelouin , it's perfect. I'm merging and publishing tomorrow.

I'll bump major then, I agree @zkochan

@acstll acstll merged commit f9b868c into snabbdom:master Nov 20, 2017
@rbelouin rbelouin deleted the escape branch November 20, 2017 18:15
@acstll
Copy link
Member

acstll commented Nov 20, 2017

Published 5.0.0, thanks again @rbelouin for such an impeccable PR!

@rbelouin
Copy link
Contributor Author

No worries!

@caramboleyo
Copy link

caramboleyo commented Dec 17, 2022

Is there a way to bypass escape? I am inserting a stringified JSON-Object in a script tag and now all " are &quot;

EDIT: I solved in in a fork by adding UNESCAPED_ELEMENTS to elements.js and an escapeText bool to renderString. I can now define tags whos children are not being escaped: 163abbf

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

Successfully merging this pull request may close these issues.

4 participants