Separated out html sanitise stuff from balance tags.
Also made it slightly more robust. git-svn-id: http://svn.automattic.com/wordpress/trunk@284 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c0757e99fb
commit
70afc0f3a6
|
@ -1113,6 +1113,20 @@ function pingback($content, $post_ID) {
|
|||
debug_fclose($log);
|
||||
}
|
||||
|
||||
/**
|
||||
** sanitise HTML attributes, remove frame/applet/*script/mouseovers,etc. tags
|
||||
** so that this kind of thing cannot be done:
|
||||
** This is how we can do <b onmouseover="alert('badbadbad')">bad stuff</b>!
|
||||
**/
|
||||
function sanitise_html_attributes($text) {
|
||||
$text = preg_replace('#( on[a-z]{1,}|style|class|id)="(.*?)"#i', '', $text);
|
||||
$text = preg_replace('#( on[a-z]{1,}|style|class|id)=\'(.*?)\'#i', '', $text);
|
||||
$text = preg_replace('#( on[a-z]{1,}|style|class|id)[ \t]*=[ \t]*([^ \t\>]*?)#i', '', $text);
|
||||
$text = preg_replace('#([a-z]{1,})="(( |\t)*?)(javascript|vbscript|about):(.*?)"#i', '$1=""', $text);
|
||||
$text = preg_replace('#([a-z]{1,})=\'(( |\t)*?)(javascript|vbscript|about):(.*?)\'#i', '$1=""', $text);
|
||||
$text = preg_replace('#\<(\/{0,1})([a-z]{0,2})(frame|applet)(.*?)\>#i', '', $text);
|
||||
return $text;
|
||||
}
|
||||
|
||||
/*
|
||||
balanceTags
|
||||
|
@ -1132,19 +1146,11 @@ function pingback($content, $post_ID) {
|
|||
Added Cleaning Hooks
|
||||
1.0 First Version
|
||||
*/
|
||||
|
||||
function balanceTags($text, $is_comment = 0) {
|
||||
global $use_balanceTags;
|
||||
|
||||
if ($is_comment) {
|
||||
$text = stripslashes($text);
|
||||
// sanitise HTML attributes, remove frame/applet tags
|
||||
$text = preg_replace('#( on[a-z]{1,}|style|class|id)="(.*?)"#i', '', $text);
|
||||
$text = preg_replace('#( on[a-z]{1,}|style|class|id)=\'(.*?)\'#i', '', $text);
|
||||
$text = preg_replace('#([a-z]{1,})="(( |\t)*?)(javascript|vbscript|about):(.*?)"#i', '$1=""', $text);
|
||||
$text = preg_replace('#([a-z]{1,})=\'(( |\t)*?)(javascript|vbscript|about):(.*?)\'#i', '$1=""', $text);
|
||||
$text = preg_replace('#\<(\/{0,1})([a-z]{0,2})(frame|applet)(.*?)\>#i', '', $text);
|
||||
$text = addslashes($text);
|
||||
$text = sanitise_html_attributes($text);
|
||||
}
|
||||
|
||||
if ($use_balanceTags == 0) {
|
||||
|
|
Loading…
Reference in New Issue