Changeset 58424 for trunk/src/wp-includes/kses.php
- Timestamp:
- 06/17/2024 12:02:50 PM (6 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/kses.php
r58418 r58424 989 989 | 990 990 </[^a-zA-Z][^>]*> # - Closing tags with invalid tag names. 991 | 992 <![^>]*> # - Invalid markup declaration nodes. Not all invalid nodes 993 # are matched so as to avoid breaking legacy behaviors. 991 994 ) 992 995 | … … 1115 1118 1116 1119 /* 1117 * When a closing tag appears with a name that isn't a valid tag name, 1118 * it must be interpreted as an HTML comment. It extends until the 1119 * first `>` character after the initial opening `</`. 1120 * When certain invalid syntax constructs appear, the HTML parser 1121 * shifts into what's called the "bogus comment state." This is a 1122 * plaintext state that consumes everything until the nearest `>` 1123 * and then transforms the entire span into an HTML comment. 1120 1124 * 1121 1125 * Preserve these comments and do not treat them like tags. 1126 * 1127 * @see https://html.spec.whatwg.org/#bogus-comment-state 1122 1128 */ 1123 if ( 1 === preg_match( '~^</[^a-zA-Z][^>]*>$~', $content ) ) { 1124 $content = substr( $content, 2, -1 ); 1125 $transformed = null; 1126 1127 while ( $transformed !== $content ) { 1128 $transformed = wp_kses( $content, $allowed_html, $allowed_protocols ); 1129 $content = $transformed; 1130 } 1131 1132 return "</{$transformed}>"; 1129 if ( 1 === preg_match( '~^(?:</[^a-zA-Z][^>]*>|<![a-z][^>]*>)$~', $content ) ) { 1130 /** 1131 * Since the pattern matches `</…>` and also `<!…>`, this will 1132 * preserve the type of the cleaned-up token in the output. 1133 */ 1134 $opener = $content[1]; 1135 $content = substr( $content, 2, -1 ); 1136 1137 do { 1138 $prev = $content; 1139 $content = wp_kses( $content, $allowed_html, $allowed_protocols ); 1140 } while ( $prev !== $content ); 1141 1142 // Recombine the modified inner content with the original token structure. 1143 return "<{$opener}{$content}>"; 1133 1144 } 1134 1145
Note: See TracChangeset
for help on using the changeset viewer.