fix: keep attributes whose name starts with an underscore#314
Open
spokodev wants to merge 1 commit into
Open
Conversation
The attribute-name regex disallowed a leading underscore, so names such
as Angular's _ngcontent-* / _nghost-* and hyperscript's _ were parsed
with the underscore stripped (getAttribute('_foo') returned undefined).
This was originally excluded to avoid a __proto__ prototype-pollution
vector (taoqf#129). Allow the leading underscore and instead reject the
literal __proto__ key explicitly, as suggested in taoqf#129, which keeps the
pollution guard while fixing taoqf#206. Values are strings, so no other key
can reach Object.prototype.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Attribute names beginning with an underscore are dropped, because the attribute regex's first-character class omits
_:_ngcontent-…becomesngcontent-…and Hyperscript's_attribute is lost._was excluded to avoid__proto__prototype pollution (#129); allow_and reject only__proto__explicitly, as suggested on #206. Attribute values are always strings, soobj['__proto__'] = <string>is a no-op and the pollution guarantees are kept (the #129 test is updated to assert them directly). Closes #206.