Skip to content
Snippets Groups Projects
Commit d5e890d0 authored by Prasad's avatar Prasad
Browse files

HTML purification to remove suspicious attributes.

parent cd8b1be4
No related branches found
No related tags found
No related merge requests found
......@@ -648,6 +648,7 @@ function vtlib_purify($input, $ignore=false) {
}
} else { // Simple type
$value = $__htmlpurifier_instance->purify($input);
$value = purifyHtmlEventAttributes($value);
}
}
$purified_cache[$md5OfInput] = $value;
......@@ -656,6 +657,23 @@ function vtlib_purify($input, $ignore=false) {
return $value;
}
/**
* To purify malicious html event attributes
* @param <String> $value
* @return <String>
*/
function purifyHtmlEventAttributes($value){
$htmlEventAttributes = "onerror|onblur|onchange|oncontextmenu|onfocus|oninput|oninvalid|".
"onreset|onsearch|onselect|onsubmit|onkeydown|onkeypress|onkeyup|".
"onclick|ondblclick|ondrag|ondragend|ondragenter|ondragleave|ondragover|".
"ondragstart|ondrop|onmousedown|onmousemove|onmouseout|onmouseover|".
"onmouseup|onmousewheel|onscroll|onwheel|oncopy|oncut|onpaste";
if(preg_match("/\s(".$htmlEventAttributes.")\s*=/i", $value)) {
$value = str_replace("=", "&equals;", $value);
}
return $value;
}
/**
* Function to return the valid SQl input.
* @param <String> $string
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment