I'm use pattern matching validation in YII1.
This is my code
array(
'sd_fname','match',
'pattern'=>'required a pattern',
'message'=> 'Invalid Characters found'
),
I want a RegEx. that can recognize following tags<script src="any_url"></script>
<link src="any_url" rel="stylesheet"></link>
The aim is to sanitize the input, to protect form XSS attack.
If there's another way for the same task, then please make me aware of that.
You can try this code for regex :
array(
'sd_fname','match',
'not' => true,
'pattern'=>'/<script.*>.*<\/script>/ims',
'message'=> 'Invalid Characters found'
),
you can test regular expression: https://regex101.com/r/fE2bX5/1