S
S
Snewer2014-04-12 19:04:55
PHP
Snewer, 2014-04-12 19:04:55

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

3 answer(s)
A
Alexey, 2014-04-12
@Snewer

HTML Purifier or equivalents. Or you can rebuild the tree using DOMDocument. Regular expressions won't work - helpless in case of XSS.

V
Vitaly Arkhipov, 2014-04-12
@arvitaly

Why not do the same with attributes - remove everything except those allowed, and those allowed to be checked for validity?

A
Alexander Borisovich, 2014-04-13
@Alexufo

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 question

Ask a Question

731 491 924 answers to any question