Clean up user-submitted HTML, preserving whitelisted elements and whitelisted attributes on a per-element basis. Built on htmlparser2 for speed and tolerance
MIT License
3.68k
stars
349
forks
source link
How can I filter values of the transform attribute? #588
For certain SVG tags I would like to allow the "transform" attribute. I would like to limit the possible values of this attribute to either "transform='translate(...)'" or "transform='rotate(...)'" where ... means any parameters for the functions indicated.
How do I achive this?
For the G element, I have tried adding the following object to the allowedAttributes:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Question or comment
For certain SVG tags I would like to allow the "transform" attribute. I would like to limit the possible values of this attribute to either "transform='translate(...)'" or "transform='rotate(...)'" where ... means any parameters for the functions indicated.
How do I achive this?
For the G element, I have tried adding the following object to the allowedAttributes:
g: { name: "transform", multiples: false, values: [ "translate", "rotate" ] }
I have also tried using wildcards like this:
g: { name: "transform", multiples: false, values: [ "translate", "rotate" ] }
And I have tried using a regular expression like this:
g: { name: "transform", multiples: false, values: [/^(translate|rotate).*$/] }
But all of these options result in the "transform" attribute being passed to the browser without any value.
Details
Node version 16.15.1 MacOS 10.14.6 Chrome browser 107.0.5304.110 (Official Build) (x86_64)