Skip to content

Commit 835a8b9

Browse files
committed
kses regex tweakage for better comment filtering. fixes WordPress#2130
git-svn-id: https://develop.svn.wordpress.org/trunk@3429 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 8a67cfd commit 835a8b9

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

wp-includes/kses.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,7 @@ function wp_kses_split($string, $allowed_html, $allowed_protocols)
7777
# matches stray ">" characters.
7878
###############################################################################
7979
{
80-
return preg_replace('%(<!--.*?-->)|(<'.# EITHER: <
81-
'[^>]*'.# things that aren't >
82-
'(>|$)'.# > or end of string
83-
'|>)%e', # OR: just a >
80+
return preg_replace('%((<!--.*?(-->|$))|(<[^>]*(>|$)|>))%e',
8481
"wp_kses_split2('\\1', \$allowed_html, ".'$allowed_protocols)', $string);
8582
} # function wp_kses_split
8683

@@ -98,10 +95,12 @@ function wp_kses_split2($string, $allowed_html, $allowed_protocols)
9895
return '&gt;';
9996
# It matched a ">" character
10097

101-
if (preg_match('%^<!--(.*)-->$%', $string, $matches)) {
102-
$string = $matches[1];
98+
if (preg_match('%^<!--(.*?)(-->)?$%', $string, $matches)) {
99+
$string = str_replace(array('<!--', '-->'), '', $matches[1]);
103100
while ( $string != $newstring = wp_kses($string, $allowed_html, $allowed_protocols) )
104101
$string = $newstring;
102+
if ( $string == '' )
103+
return '';
105104
return "<!--{$string}-->";
106105
}
107106
# Allow HTML comments

0 commit comments

Comments
 (0)