i need to find inline javascript with php regex. I can find external script, but not inline, can anybody help me?
Here is my pattern for external:
"/<script(.*?)src(.*?)>(.*?)<\/script\s*>/smi"
Any ideas?
i need to find inline javascript with php regex. I can find external script, but not inline, can anybody help me?
Here is my pattern for external:
"/<script(.*?)src(.*?)>(.*?)<\/script\s*>/smi"
Any ideas?
"/<script((?:(?!src=).)*?)>(.*?)<\/script>/smix"
(My first look-ahead regex ;))
Please note that you should not parse HTML with regexes, see:
You need to find all those cases where inline script can be used (i.e. all listener functions onClick, onBlur, onMouseDown, onMouseUp, on...)).
<iframe src="http://example.com/evil.htm"></iframe>. A better solution would be whitelisting using an application like HTML Purifier."/<script[^\>]*>(.?)<\/script>/si"