-
-
Notifications
You must be signed in to change notification settings - Fork 723
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
[bug] Breaking changes with tag matching (_isBasicCustomElement) in 3.0.10 #920
Comments
Oha, well spotted, thanks - we might change the regex to this, likely that woulf fix the issue, no?
|
Ignoring the hexadecimal values, the standard suggests the potential use of It should also follow this structure: If we split these rules into groups, we have: ([a-z])([-._a-z\d]*)(\-)([-._a-z\d]*) Play around with regex rules here: https://regex101.com/r/zSEBkx/1 MDN also specifies that it
Not sure if you want to be strict about the use of Potential full code:export const CUSTOM_ELEMENT = seal(/^([a-z])([-._a-z\d]*)(\-)([-._a-z\d]*)$/i); |
Thanks, the proposed RegEx however is vulnerable to ReDos 🙂 This one should achieve mostly the same and be safe(r) and also match your example well:
Wdyt? |
Background & Context
When sanitizing a string (in
DOMPurify.sanitize
) with a custom element, it doesn't allow underscores (_
) in_isBasicCustomElement
method.Currently accepted Regex:
/^[a-z][a-z\d]*(-[a-z\d]+)+$/i
Bug
Input
with
CUSTOM_ELEMENT_HANDLING
'stagNameCheck
in options set to(tagName) => RegExp(/^customtag-/).exec(tagName)
Given output of
_isBasicCustomElement
null
Expected output of
_isBasicCustomElement
["customtag-my-custom-element_v1"]
Feature
stringMatch(tagName, CUSTOM_ELEMENT)
doesn't pick up_
in tags. The Regex should be extended to include underscores.Docs on a valid custom element name
MDN:
The text was updated successfully, but these errors were encountered: