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

Avoid sanitizing 'on' attr with DOMPurify #15820

Merged
merged 3 commits into from Jun 6, 2018

Conversation

dreamofabear
Copy link

Fixes #15721.

/to @alabiaga

src/sanitizer.js Outdated
const {name, value} = r.attribute;
// Restore the `on` attribute which DOMPurify incorrectly flags as an
// unknown protocol due to presence of the `:` character.
if (name.toLocaleLowerCase() === 'on') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we do toLocaleLowerCase? toLowerCase should suffice? Similarly in this line,

const tagName = node.nodeName.toLocaleLowerCase();

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was to be consistent with DOMPurify's internal usage, but toLowerCase should be fine. Fixed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotcha. Thanks

@dreamofabear dreamofabear merged commit e1a51c4 into ampproject:master Jun 6, 2018
@dreamofabear dreamofabear deleted the purify-on-attr branch June 6, 2018 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants