@@ -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 '> ' ;
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