Closed jeff-an closed 1 month ago
Hey @jeff-an, thanks for the bug report. I have just published v3.6.9
with the fix. The base64 encoded src
attributes are now ignored.
Awesome, thanks for the fast fix! It might be good to also have a generic predicate configurable so that people can decide to ignore attributes programmatically, e.g.:
{
attrributeFilter: (attrName: string, attrVal: string | null) => boolean
}
I tried to use this library to generate a selector for an image element with an extremely long src attr that has inlined base64 data. This caused the browser to hang indefinitely.
The problem seems to occur only if the blacklist includes a regex pattern. Even a matching regex pattern like
/.*\[.*src.*data:.*\].*/
will cause the library to hang, presumably due to regex matching hogging the event loop. Switching to a more simple blacklist like exact string matches seems to fix the issue.So my feature request would be to maybe support a
timeout
parameter, add docs warning about regex usage, and adding an option to refuse to use attributes above a certain length. Themedv
selector generator has a similar option that just lets you pass a predicate for attributes.If you point me to some relevant code, I'm happy to make a pull request as well! Thanks!