i am trying to find out scrip tag both open() and close() in my php string.Please find my code below
public function custom_xss_clean($str){
if(!preg_match('/(<\/?)(script|html)(>*)/i', $str)){
return true;
} else {
$this->form_validation->set_message('custom_xss_clean','The %s field invalid');
return false;
}
}
This code is working fine in online tool but not in my code for string
<script>alert(10)</script>
I have tried so many pattern but no luck.Please help thanks in advance.
Try This
preg_match('/<script>[a-zA-Z0-9 \. \n \t\r \* \\ \* ~`!@#$%^&*()-_+={}\[\]\'":;?\/><.,|]*<\/script>/', $str);
Am Tested also you can check live https://regex101.com/r/ih2C3F/1/