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

fix(utils): remove attributes from source string #2803

Merged
merged 11 commits into from
Mar 4, 2021
Merged

Conversation

straker
Copy link
Contributor

@straker straker commented Feb 12, 2021

Remove unwanted attributes from source string. Will add all the audit code around it in another pr so this one doesn't get too big.

For the record; this does add a small feature, but it is a feature necessary to address a security fix that will need to be applied to all supported minor versions of axe-core. We are therefor tagging this as a "fix" instead of a "feat".

@straker straker changed the title fix(DqElement): remove attributes from source string fix(utils): remove attributes from source string Feb 15, 2021
@straker straker marked this pull request as ready for review February 15, 2021 22:26
@straker straker requested a review from a team as a code owner February 15, 2021 22:26
lib/core/utils/filter-html-attrs.js Outdated Show resolved Hide resolved
lib/core/utils/filter-html-attrs.js Outdated Show resolved Hide resolved
lib/core/utils/filter-html-attrs.js Outdated Show resolved Hide resolved
lib/core/utils/filter-html-attrs.js Outdated Show resolved Hide resolved
lib/core/utils/filter-html-attrs.js Outdated Show resolved Hide resolved
lib/core/utils/filter-html-attrs.js Outdated Show resolved Hide resolved
lib/core/utils/filter-html-attrs.js Outdated Show resolved Hide resolved
test/core/utils/filter-html-attrs.js Outdated Show resolved Hide resolved
test/core/utils/filter-html-attrs.js Outdated Show resolved Hide resolved
@straker
Copy link
Contributor Author

straker commented Feb 22, 2021

Went with using the node itself to apply css selector matching.

node.appendChild(filterHtmlAttrs(child, filterAttrs));
});

return node;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this returning elements? Isn't doing a bit of string manipulation much faster than creating entirely new DOM structures?

Copy link
Contributor Author

@straker straker Mar 3, 2021

Choose a reason for hiding this comment

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

If we're matching CSS selectors we cannot work on just strings. I wanted to remove attributes but IE11 wouldn't remove value from an input element so had to instead recreate the DOM from scratch. Since the elements are not part of the DOM they shouldn't incur any performance penalties by reflow or repaints.

test/core/utils/filter-html-attrs.js Show resolved Hide resolved
@straker straker merged commit 8e8c4fa into develop Mar 4, 2021
@straker straker deleted the sanitize-attrs branch March 4, 2021 17:43
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.

2 participants