kses regex tweakage for better comment filtering. fixes #2130
git-svn-id: http://svn.automattic.com/wordpress/trunk@3429 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
acff9479ff
commit
558711072b
|
@ -77,10 +77,7 @@ function wp_kses_split($string, $allowed_html, $allowed_protocols)
|
||||||
# matches stray ">" characters.
|
# matches stray ">" characters.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
{
|
{
|
||||||
return preg_replace('%(<!--.*?-->)|(<'.# EITHER: <
|
return preg_replace('%((<!--.*?(-->|$))|(<[^>]*(>|$)|>))%e',
|
||||||
'[^>]*'.# things that aren't >
|
|
||||||
'(>|$)'.# > or end of string
|
|
||||||
'|>)%e', # OR: just a >
|
|
||||||
"wp_kses_split2('\\1', \$allowed_html, ".'$allowed_protocols)', $string);
|
"wp_kses_split2('\\1', \$allowed_html, ".'$allowed_protocols)', $string);
|
||||||
} # function wp_kses_split
|
} # function wp_kses_split
|
||||||
|
|
||||||
|
@ -98,10 +95,12 @@ function wp_kses_split2($string, $allowed_html, $allowed_protocols)
|
||||||
return '>';
|
return '>';
|
||||||
# It matched a ">" character
|
# It matched a ">" character
|
||||||
|
|
||||||
if (preg_match('%^<!--(.*)-->$%', $string, $matches)) {
|
if (preg_match('%^<!--(.*?)(-->)?$%', $string, $matches)) {
|
||||||
$string = $matches[1];
|
$string = str_replace(array('<!--', '-->'), '', $matches[1]);
|
||||||
while ( $string != $newstring = wp_kses($string, $allowed_html, $allowed_protocols) )
|
while ( $string != $newstring = wp_kses($string, $allowed_html, $allowed_protocols) )
|
||||||
$string = $newstring;
|
$string = $newstring;
|
||||||
|
if ( $string == '' )
|
||||||
|
return '';
|
||||||
return "<!--{$string}-->";
|
return "<!--{$string}-->";
|
||||||
}
|
}
|
||||||
# Allow HTML comments
|
# Allow HTML comments
|
||||||
|
|
Loading…
Reference in New Issue