Skip to content

fix: keep attributes whose name starts with an underscore#314

Open
spokodev wants to merge 1 commit into
taoqf:mainfrom
spokodev:fix/leading-underscore-attributes
Open

fix: keep attributes whose name starts with an underscore#314
spokodev wants to merge 1 commit into
taoqf:mainfrom
spokodev:fix/leading-underscore-attributes

Conversation

@spokodev

@spokodev spokodev commented Jul 8, 2026

Copy link
Copy Markdown

Attribute names beginning with an underscore are dropped, because the attribute regex's first-character class omits _:

parse('<div _foo="bar">').firstChild.getAttribute('_foo') // undefined (expected 'bar')

_ngcontent-… becomes ngcontent-… 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, so obj['__proto__'] = <string> is a no-op and the pollution guarantees are kept (the #129 test is updated to assert them directly). Closes #206.

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.
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.

Omits _ attribute used by Hyperscript

1 participant