Answer the question
In order to leave comments, you need to log in
Clearing html attributes
Hello!
What is the best way to clean up custom html?
I do so:
1. I delete all tags, except resolved
2. I delete attributes reg. expression: ~\s*(on*).*\=.*\".*\"~is
what do you recommend? and how miserable reg. expression?
Answer the question
In order to leave comments, you need to log in
HTML Purifier or equivalents. Or you can rebuild the tree using DOMDocument. Regular expressions won't work - helpless in case of XSS.
Why not do the same with attributes - remove everything except those allowed, and those allowed to be checked for validity?
look at tinymce for regular expression code. There, on account of this, everything that your heart desires is configured. Excellent visualizer.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question