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

Incorrect handling of html entities in attributes #276

Closed
vdanchenkov opened this issue May 12, 2019 · 0 comments · Fixed by mozilla/fxa#7842
Closed

Incorrect handling of html entities in attributes #276

vdanchenkov opened this issue May 12, 2019 · 0 comments · Fixed by mozilla/fxa#7842

Comments

@vdanchenkov
Copy link

vdanchenkov commented May 12, 2019

Latest version of entities modules decodes it correctly:

require("entities").decodeHTML("?&image_uri=1&ℑ=2");
// returns ?&image_uri=1&ℑ=2

Htmlparser2 decodes it incorrectly in attributes, while everything is ok in text node.

var DOM = require("htmlparser2").parseDOM(
    '<img src="?&image_uri=1&&image;=2"/><div>?&image_uri=1&&image;=2</div>',
    { decodeEntities: true }
);

// DOM[0].attribs.src is wrong = `?ℑuri=1&ℑ=2`
// DOM[1].children[0].data is correct = `?&image_uri=1&ℑ=2`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant