Changeset 64233
- Timestamp:
- 10/07/2026 07:52:13 PM (5 weeks ago)
- Location:
- trunk
- Files:
-
- 26 edited
-
src/wp-includes/default-filters.php (modified) (1 diff)
-
src/wp-includes/formatting.php (modified) (3 diffs)
-
src/wp-includes/kses.php (modified) (4 diffs)
-
tests/phpunit/tests/admin/includesTemplate.php (modified) (4 diffs)
-
tests/phpunit/tests/block-bindings/postMetaSource.php (modified) (1 diff)
-
tests/phpunit/tests/block-bindings/render.php (modified) (2 diffs)
-
tests/phpunit/tests/block-bindings/termDataSource.php (modified) (1 diff)
-
tests/phpunit/tests/customize/manager.php (modified) (3 diffs)
-
tests/phpunit/tests/customize/nav-menu-item-setting.php (modified) (1 diff)
-
tests/phpunit/tests/formatting/sanitizeTextField.php (modified) (2 diffs)
-
tests/phpunit/tests/functions/wpTriggerError.php (modified) (1 diff)
-
tests/phpunit/tests/icons/wpRestIconsController.php (modified) (1 diff)
-
tests/phpunit/tests/kses.php (modified) (12 diffs)
-
tests/phpunit/tests/link/getThePrivacyPolicyLink.php (modified) (1 diff)
-
tests/phpunit/tests/media.php (modified) (5 diffs)
-
tests/phpunit/tests/post/output.php (modified) (1 diff)
-
tests/phpunit/tests/post/wpPublishPost.php (modified) (2 diffs)
-
tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportGroupHtml.php (modified) (2 diffs)
-
tests/phpunit/tests/rest-api/rest-attachments-controller.php (modified) (2 diffs)
-
tests/phpunit/tests/rest-api/rest-comments-controller.php (modified) (1 diff)
-
tests/phpunit/tests/rest-api/rest-posts-controller.php (modified) (2 diffs)
-
tests/phpunit/tests/rest-api/rest-tags-controller.php (modified) (3 diffs)
-
tests/phpunit/tests/rest-api/rest-users-controller.php (modified) (3 diffs)
-
tests/phpunit/tests/rest-api/rest-widgets-controller.php (modified) (1 diff)
-
tests/phpunit/tests/rest-api/wpRestUrlDetailsController.php (modified) (1 diff)
-
tests/phpunit/tests/widgets/wpWidgetMediaImage.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/default-filters.php
r64120 r64233 307 307 add_filter( 'pre_kses', 'wp_pre_kses_less_than' ); 308 308 add_filter( 'pre_kses', 'wp_pre_kses_block_attributes', 10, 3 ); 309 add_filter( 'wp_kses_force_legacy_parser', '__return_false' ); 309 310 add_filter( 'sanitize_title', 'sanitize_title_with_dashes', 10, 3 ); 310 311 add_action( 'check_comment_flood', 'check_comment_flood_db', 10, 4 ); -
trunk/src/wp-includes/formatting.php
r64163 r64233 5319 5319 * @since 2.3.0 5320 5320 * 5321 * @global string $wp_kses_operating_mode Indicates if this filter should run. 5322 * 5321 5323 * @param string $content Text to be converted. 5322 5324 * @return string Converted text. 5323 5325 */ 5324 5326 function wp_pre_kses_less_than( $content ) { 5327 global $wp_kses_operating_mode; 5328 5329 if ( 'legacy' !== ( $wp_kses_operating_mode ?? 'legacy' ) ) { 5330 return $content; 5331 } 5332 5325 5333 return preg_replace_callback( '%<[^>]*?((?=<)|>|$)%', 'wp_pre_kses_less_than_callback', $content ); 5326 5334 } … … 5346 5354 * 5347 5355 * @since 5.3.1 5356 * 5357 * @global string $wp_kses_operating_mode Indicates if this filter should run. 5348 5358 * 5349 5359 * @param string $content Content to be run through KSES. … … 5355 5365 */ 5356 5366 function wp_pre_kses_block_attributes( $content, $allowed_html, $allowed_protocols ) { 5367 global $wp_kses_operating_mode; 5368 5369 if ( 'legacy' !== ( $wp_kses_operating_mode ?? 'legacy' ) ) { 5370 return $content; 5371 } 5372 5357 5373 /* 5358 5374 * `filter_block_content` is expected to call `wp_kses`. Temporarily remove -
trunk/src/wp-includes/kses.php
r64163 r64233 56 56 // (e.g. if using namespaces / autoload in the current PHP environment). 57 57 global $allowedposttags, $allowedtags, $allowedentitynames, $allowedxmlentitynames; 58 59 /** 60 * Indicates which implementation of {@see \wp_kses()} is running. 61 * 62 * Nominally `legacy` unless temporarily-switched for {@see \wp_sanitize_html_kses()}. 63 * It’s safe to latch this into `legacy`. 64 * 65 * @global 'legacy'|'html-api' $wp_kses_operating_mode 66 * 67 * @since 7.2.0 68 */ 69 global $wp_kses_operating_mode; 70 $wp_kses_operating_mode = 'legacy'; 58 71 59 72 if ( ! CUSTOM_TAGS ) { … … 949 962 * @see wp_allowed_protocols() for the default allowed protocols in link URLs. 950 963 * 964 * @see 'wp_kses_force_legacy_parser' to opt-out of the new HTML-API-based implementation. 965 * 951 966 * @since 1.0.0 967 * @since 7.2.0 Rewritten with the HTML API for more reliable parsing. 968 * 969 * @global string $wp_kses_operating_mode 952 970 * 953 971 * @param string $content Text content to filter. 954 972 * @param array[]|string $allowed_html An array of allowed HTML elements and attributes, 955 * or a context name such as 'post'. See wp_kses_allowed_html()973 * or a context name such as 'post'. {@see wp_kses_allowed_html()} 956 974 * for the list of accepted context names. 957 975 * @param string[] $allowed_protocols Optional. Array of allowed URL protocols. … … 960 978 */ 961 979 function wp_kses( $content, $allowed_html, $allowed_protocols = array() ) { 980 global $wp_kses_operating_mode; 981 982 /** 983 * Filters whether to rely on the legacy parsing inside `wp_kses()`. 984 * 985 * @since 7.2.0 986 * 987 * @param bool $force_legacy_parser Whether to force using the legacy parser 988 * instead of relying on the HTML API. 989 */ 990 if ( ! apply_filters( 'wp_kses_force_legacy_parser', true ) ) { 991 return wp_sanitize_html_kses( (string) $content, $allowed_html, $allowed_protocols ); 992 } 993 962 994 if ( empty( $allowed_protocols ) ) { 963 995 $allowed_protocols = wp_allowed_protocols(); … … 966 998 $content = wp_kses_no_null( $content, array( 'slash_zero' => 'keep' ) ); 967 999 $content = wp_kses_normalize_entities( $content ); 968 $content = wp_kses_hook( $content, $allowed_html, $allowed_protocols ); 1000 1001 // Ensure that the legacy pre-kses filters run by setting the operating mode appropriately. 1002 try { 1003 $previous_kses_mode = $wp_kses_operating_mode; 1004 $wp_kses_operating_mode = 'legacy'; 1005 $content = wp_kses_hook( $content, $allowed_html, $allowed_protocols ); 1006 } finally { 1007 $wp_kses_operating_mode = $previous_kses_mode; 1008 } 969 1009 970 1010 return wp_kses_split( $content, $allowed_html, $allowed_protocols ); 1011 } 1012 1013 /** 1014 * Filters HTML content, sanitizing according to given policies. 1015 * 1016 * Modern implementation of {@see wp_kses()} built with the HTML API. 1017 * 1018 * @since 7.2.0 1019 * 1020 * @global string $wp_kses_operating_mode 1021 * 1022 * @access private This function should not be called directly, as it serves a transitionary 1023 * role while replacing the implementation of {@see \wp_kses()}. 1024 * 1025 * @param string $content Text content to filter. 1026 * @param array[]|string $allowed_html An array of allowed HTML elements and attributes, 1027 * or a context name such as 'post'. See wp_kses_allowed_html() 1028 * for the list of accepted context names. 1029 * @param string[] $allowed_protocols Optional. Array of allowed URL protocols. 1030 * Defaults to the result of wp_allowed_protocols(). 1031 * @return string Filtered content containing only the allowed HTML. 1032 */ 1033 function wp_sanitize_html_kses( $content, $allowed_html, $allowed_protocols = array() ) { 1034 global $wp_kses_operating_mode; 1035 1036 $specified_allowed_html = $allowed_html; 1037 1038 $allowed_protocols = empty( $allowed_protocols ) 1039 ? wp_allowed_protocols() 1040 : $allowed_protocols; 1041 1042 // Preserve legacy behavior of stripping unwanted C0 control characters. 1043 $content = preg_replace( '/[\x01-\x08\x0B\x0C\x0E-\x1F]/', '', $content ); 1044 1045 /* 1046 * Call legacy pre-kses filters that might have been added by plugins. 1047 * 1048 * Also set the operating mode to bypass the pre-filters from the legacy 1049 * implementation of `wp_kses()`, as these filters are now run in-band 1050 * during the processing of the input document. 1051 */ 1052 try { 1053 $previous_kses_mode = $wp_kses_operating_mode; 1054 $wp_kses_operating_mode = 'html-api'; 1055 $content = wp_kses_hook( $content, $specified_allowed_html, $allowed_protocols ); 1056 } finally { 1057 $wp_kses_operating_mode = $previous_kses_mode; 1058 } 1059 1060 $allowed_html = is_array( $allowed_html ) 1061 ? $allowed_html 1062 : wp_kses_allowed_html( $allowed_html ); 1063 1064 /* 1065 * The explanation for this call is that “the quoting from `preg_replace(//e)` 1066 * requires” it, but this version of `wp_kses()` doesn’t rely on PCRE functions 1067 * to parse HTML. Given that this corrupts text, it will be skipped. 1068 */ 1069 //$content = wp_kses_stripslashes( $content ); 1070 1071 $processor = new class( $content, $specified_allowed_html, $allowed_html, $allowed_protocols, wp_kses_uri_attributes() ) extends WP_HTML_Tag_Processor { 1072 /** 1073 * An array of allowed HTML elements and attributes, or a context name such as 'post'. 1074 * 1075 * It’s important to store this alongside the resolved allowable HTML because some 1076 * filters in some plugins look for the string values, e.g. for “post” instead of 1077 * the resolved array, and apply logic based on that context. 1078 * 1079 * @see wp_kses_allowed_html() for the list of accepted context names. 1080 * @see self::$allowed_html for the resolved array of allowable HTML elements and attributes. 1081 * 1082 * @since 7.2.0 1083 * 1084 * @var array[]|string 1085 */ 1086 private $specified_allowed_html; 1087 1088 /** 1089 * An array of allowed HTML elements and attributes. 1090 * 1091 * This array of allowable HTML elements and attributes is resolved from the value provided 1092 * to the sanitizer function. It’s resolved at the start to avoid repeatedly calling the 1093 * filter stack and array-merging computations. However, it’s still necessary to carry along 1094 * the provided context so that filters expecting the array-or-string version continue to 1095 * operate properly. 1096 * 1097 * @see self::$specified_allowed_html 1098 * 1099 * @since 7.2.0 1100 * 1101 * @var array[] 1102 */ 1103 private $allowed_html; 1104 1105 /** 1106 * Array of allowed URL protocols. 1107 * 1108 * @see \wp_allowed_protocols() 1109 * 1110 * @since 7.2.0 1111 * 1112 * @var string[] 1113 */ 1114 private $allowed_protocols; 1115 1116 /** 1117 * List of attributes whose values are expected to be considered URLs. 1118 * 1119 * @see \wp_kses_uri_attributes() 1120 * 1121 * @since 7.2.0 1122 * 1123 * @var string[] 1124 */ 1125 private $uri_attributes; 1126 1127 /** 1128 * Tracks balanced tags when inside foreign content. 1129 * 1130 * @since 7.2.0 1131 * 1132 * @var string[] 1133 */ 1134 private $foreign_content_stack = array(); 1135 1136 /** 1137 * Tracks how deeply into a MathML ANNOTATION-XML element the current token is; 1138 * an optimization to avoid checking up the open-element stack on every token. 1139 * 1140 * @since 7.2.0 1141 * 1142 * @var int 1143 */ 1144 private $math_annotation_xml_depth = 0; 1145 1146 /** 1147 * Constructor function, used internally. 1148 * 1149 * @since 7.2.0 1150 * @access private 1151 * 1152 * @param string $html Content to filter. 1153 * @param array[]|string $specified_allowed_html Context passed into sanitizer. 1154 * @param array[] $allowed_html Resolved allowable HTML. 1155 * @param string[] $allowed_protocols Resolved allowable protocols. 1156 * @param string[] $uri_attributes Resolved URI attributes. 1157 */ 1158 public function __construct( $html, $specified_allowed_html, $allowed_html, $allowed_protocols, $uri_attributes ) { 1159 parent::__construct( $html ); 1160 1161 $this->specified_allowed_html = $specified_allowed_html; 1162 $this->allowed_html = $allowed_html; 1163 $this->allowed_protocols = $allowed_protocols; 1164 $this->uri_attributes = $uri_attributes; 1165 } 1166 1167 /** 1168 * Returns the raw byte-span of the currently-matched token, 1169 * assuming that the parser is matched on a token. 1170 * 1171 * @since 7.2.0 1172 * @access private 1173 * 1174 * @return WP_HTML_Span|null 1175 */ 1176 private function get_span() { 1177 $this->set_bookmark( 'here' ); 1178 1179 if ( ! isset( $this->bookmarks['here'] ) ) { 1180 return null; 1181 } 1182 1183 return $this->bookmarks['here']; 1184 } 1185 1186 /** 1187 * Sets the value of a given HTML attribute, adjusting URL attributes 1188 * to ensure compatibility with legacy {@see wp_kses()} behavior. 1189 * 1190 * @since 7.2.0 1191 * @access private 1192 * 1193 * @param string $name Name of HTML attribute to set. 1194 * @param string|true $value Value to set; `true` for boolean attribute. 1195 * @return bool Whether the attribute was set. 1196 */ 1197 public function set_attribute( $name, $value ): bool { 1198 $lower_name = strtolower( $name ); 1199 $is_url_ish = in_array( $lower_name, $this->uri_attributes, true ); 1200 1201 if ( ! $is_url_ish || ! is_string( $value ) ) { 1202 return parent::set_attribute( $name, $value ); 1203 } 1204 1205 $escaped = strtr( 1206 $value, 1207 array( 1208 '<' => '<', 1209 '>' => '>', 1210 '&' => '&', 1211 '"' => '"', 1212 "'" => ''', 1213 ) 1214 ); 1215 1216 // Set a benign placeholder to replace below. 1217 if ( ! parent::set_attribute( $name, true ) ) { 1218 return false; 1219 } 1220 1221 $this->lexical_updates[ $lower_name ]->text = " {$lower_name}=\"{$escaped}\""; 1222 1223 return true; 1224 } 1225 1226 /** 1227 * Indicates if the currently-matched token, given the parsed context, would require more 1228 * complicated parsing rules to proceed without risking escape from foreign content. 1229 * 1230 * @since 7.2.0 1231 * @access private 1232 * 1233 * @param bool $is_inside_mathml_text_integration_point 1234 * @param bool $is_inside_svg_html_integration_point 1235 * @return bool 1236 */ 1237 private function could_escape_foreign_content( bool $is_inside_mathml_text_integration_point, bool $is_inside_svg_html_integration_point ): bool { 1238 $token_name = $this->get_token_name(); 1239 $is_closer = $this->is_tag_closer(); 1240 $namespace = $this->get_namespace(); 1241 $self_closing = ! $is_closer && $this->has_self_closing_flag(); 1242 1243 if ( ! $is_closer && $is_inside_svg_html_integration_point ) { 1244 return true; 1245 } 1246 1247 /* 1248 * These two elements are excepted in HTML from the normal processing 1249 * rules because they function in similar ways to character data. 1250 * 1251 * > The mglyph element is used to represent non-standard characters or 1252 * > symbols by images; the malignmark element establishes an alignment 1253 * > point for use within table constructs, and is otherwise invisible. 1254 * 1255 * They must contain no elements, so only allow self-closing tags. 1256 */ 1257 if ( ! $is_closer && $is_inside_mathml_text_integration_point ) { 1258 return ! ( $self_closing && ( 'MGLYPH' === $token_name || 'MALIGNMARK' === $token_name ) ); 1259 } 1260 1261 if ( 1262 ! $is_closer && 1263 'FONT' === $token_name && 1264 ( 1265 null !== $this->get_attribute( 'color' ) || 1266 null !== $this->get_attribute( 'face' ) || 1267 null !== $this->get_attribute( 'size' ) 1268 ) 1269 ) { 1270 return true; 1271 } 1272 1273 if ( 1274 ! $is_closer && 1275 in_array( 1276 $token_name, 1277 array( 1278 'B', 1279 'BIG', 1280 'BLOCKQUOTE', 1281 'BODY', 1282 'BR', 1283 'CENTER', 1284 'CODE', 1285 'DD', 1286 'DIV', 1287 'DL', 1288 'DT', 1289 'EM', 1290 'EMBED', 1291 'H1', 1292 'H2', 1293 'H3', 1294 'H4', 1295 'H5', 1296 'H6', 1297 'HEAD', 1298 'HR', 1299 'I', 1300 'IMG', 1301 'LI', 1302 'LISTING', 1303 'MENU', 1304 'META', 1305 'NOBR', 1306 'OL', 1307 'P', 1308 'PRE', 1309 'RUBY', 1310 'S', 1311 'SMALL', 1312 'SPAN', 1313 'STRONG', 1314 'STRIKE', 1315 'SUB', 1316 'SUP', 1317 'TABLE', 1318 'TT', 1319 'U', 1320 'UL', 1321 'VAR', 1322 ), 1323 true 1324 ) || 1325 ( 1326 $is_closer && 1327 in_array( 1328 $token_name, 1329 array( 1330 'BR', 1331 'P', 1332 ), 1333 true 1334 ) 1335 ) 1336 ) { 1337 return true; 1338 } 1339 1340 if ( 'math' === $namespace && ! $is_closer && ! $self_closing ) { 1341 $encoding = $this->get_attribute( 'encoding' ); 1342 if ( 1343 'ANNOTATION-XML' === $token_name && 1344 is_string( $encoding ) && 1345 ( 1346 0 === strcasecmp( $encoding, 'text/html' ) || 1347 0 === strcasecmp( $encoding, 'application/xhtml+xml' ) 1348 ) 1349 ) { 1350 return true; 1351 } 1352 1353 /* 1354 * When SVG becomes a direct descendant of a MathML ANNOTATION-XML, 1355 * the namespace remains `math` but there could be an SVG element 1356 * with an HTML integration point. Conservatively reject any child 1357 * SVG element inside a MathML ANNOTATION-XML to prevent this. 1358 */ 1359 if ( 'SVG' === $token_name && $this->math_annotation_xml_depth > 0 ) { 1360 return true; 1361 } 1362 } 1363 1364 return false; 1365 } 1366 1367 /** 1368 * Indicates if a given string contains text that would parse as a block delimiter. 1369 * 1370 * @since 7.2.0 1371 * @access private 1372 * 1373 * @param string $text Does a block comment delimiter exist in this string value? 1374 * @return bool Whether a block comment delimiter of any kind was found in the given string. 1375 */ 1376 private static function contains_a_block_delimiter( string $text ): bool { 1377 if ( '' === $text ) { 1378 return false; 1379 } 1380 1381 $processor = new WP_Block_Processor( $text ); 1382 1383 return $processor->next_delimiter(); 1384 } 1385 1386 /** 1387 * Returns a sanitized copy of the input HTML. 1388 * 1389 * @since 7.2.0 1390 * @access private 1391 * 1392 * @return string Sanitized copy of given input HTML. 1393 */ 1394 public function sanitize() { 1395 $template_depth = 0; 1396 $output = ''; 1397 $special_newline_at = PHP_INT_MIN; 1398 $foreign_content_starts_at = PHP_INT_MAX; 1399 $open_blocks = array(); 1400 $open_blocks_at = array(); 1401 $foreign_closed_blocks = array(); 1402 1403 $is_in_mathml_text_integration_point = false; 1404 $is_in_svg_html_integration_point = false; 1405 1406 /** 1407 * These are treated as void elements inside the HTML API 1408 * due to the special handling of their inner text content. 1409 */ 1410 $special_atomic_elements = array( 1411 'IFRAME', 1412 'NOEMBED', 1413 'NOFRAMES', 1414 'SCRIPT', 1415 'STYLE', 1416 'TEXTAREA', 1417 'TITLE', 1418 'XMP', 1419 ); 1420 1421 while ( $this->next_token() ) { 1422 $token_name = $this->get_token_name(); 1423 $token_type = $this->get_token_type(); 1424 $namespace = $this->get_namespace(); 1425 $is_closer = $this->is_tag_closer(); 1426 $here = $this->get_span(); 1427 1428 /* 1429 * Prevent allowing NOSCRIPT elements whose parsing rules change 1430 * based on whether the scripting flag is enabled in a browser. 1431 * Rely on trusted inputs for producing the appropriate NOSCRIPT 1432 * content, and prevent untrusted inputs from generating it. 1433 */ 1434 if ( 'NOSCRIPT' === $token_name && ! $is_closer ) { 1435 break; 1436 } 1437 1438 /* 1439 * PLAINTEXT is unique in that it changes the tokenization. Everything in 1440 * a document following the PLAINTEXT opening tag is interpreted as character 1441 * data, meaning there are no more tags, comments, or anything. Because of 1442 * this, it is the only element without a closing tag. 1443 * 1444 * Because of its unique role, it’s risky to leave in place because very few 1445 * parsers are going to recognize the tag and properly switch modes for the 1446 * rest of the document. Instead, the PLAINTEXT tag is removed and its content 1447 * is re-written as an escaped text node. 1448 * 1449 * This changes the structure of the document, because no PLAINTEXT element 1450 * will appear, and it won’t be possible to style its contents, but the element 1451 * is discouraged anyway and should not be allowed from untrusted inputs. 1452 */ 1453 if ( 'PLAINTEXT' === $token_name && 'html' === $namespace && ! $is_closer ) { 1454 if ( $template_depth > 0 && ! isset( $this->allowed_html['template'] ) ) { 1455 break; 1456 } 1457 1458 $text = substr( $this->html, $here->start + $here->length ); 1459 1460 $needs_special_newline = ( 1461 strlen( $output ) === $special_newline_at && 1462 1 === strspn( $text, "\n\r", 0, 1 ) 1463 ); 1464 1465 if ( $needs_special_newline ) { 1466 $output .= "\n"; 1467 } 1468 1469 $output .= strtr( 1470 $text, 1471 array( 1472 "\x00" => "\u{FFFD}", 1473 "\r\n" => "\n", 1474 "\r" => "\n", 1475 '<' => '<', 1476 '&' => '&', 1477 '>' => '>', 1478 ) 1479 ); 1480 1481 break; 1482 } 1483 1484 $is_in_text_integration_point = ( 1485 $is_in_mathml_text_integration_point || 1486 ( ! $is_closer && $is_in_svg_html_integration_point ) 1487 ); 1488 1489 /* 1490 * While content inside integration points is generally not allowed here, 1491 * character data inside the MathML text elements _is_ allowed. This is 1492 * because the rules only change slightly: NULL bytes are removed instead 1493 * of being replaced with the Unicode replacement character U+FFFD; and 1494 * active formats are reconstructed. The format reconstruction doesn’t 1495 * occur here but a browser will still do so; this sanitizer is generally 1496 * unaware of nesting structure. 1497 */ 1498 if ( $is_in_text_integration_point && '#text' === $token_type ) { 1499 $this->change_parsing_namespace( 'html' ); 1500 $text = $this->get_modifiable_text(); 1501 $this->change_parsing_namespace( $namespace ); 1502 } else { 1503 $text = $this->get_modifiable_text(); 1504 } 1505 1506 /* 1507 * Enter the foreign content and change the parsing namespace 1508 * so that the parser recognizes real self-closing elements. 1509 */ 1510 $is_svg_or_math = 'MATH' === $token_name || 'SVG' === $token_name; 1511 $has_self_closing_flag = ! $is_closer && $this->has_self_closing_flag(); 1512 if ( $is_svg_or_math && ! $is_closer && 'html' === $namespace ) { 1513 $this->change_parsing_namespace( strtolower( $token_name ) ); 1514 $namespace = $this->get_namespace(); 1515 } 1516 1517 if ( 'html' !== $namespace && '#tag' === $token_type ) { 1518 /* 1519 * Ensure that only well-formed foreign content is allowed. 1520 * Since un-balanced closing tags might implicitly close the 1521 * open foreign-content element, these must be rejected. 1522 */ 1523 if ( $is_closer ) { 1524 $open_element = array_pop( $this->foreign_content_stack ); 1525 if ( null === $open_element || $token_name !== $open_element ) { 1526 break; 1527 } 1528 1529 if ( 'math' === $namespace && 'ANNOTATION-XML' === $open_element ) { 1530 --$this->math_annotation_xml_depth; 1531 } 1532 1533 /* 1534 * Reset the foreign content tracker so it doesn’t truncate 1535 * unintentionally after foreign content has properly closed. 1536 */ 1537 if ( empty( $this->foreign_content_stack ) ) { 1538 $foreign_content_starts_at = PHP_INT_MAX; 1539 } 1540 } else { 1541 /* 1542 * Track the opening of the last transition into foreign 1543 * content so that it can be discarded when encountering 1544 * tags that would require more substantial parsing. 1545 */ 1546 if ( empty( $this->foreign_content_stack ) ) { 1547 $foreign_content_starts_at = strlen( $output ); 1548 } 1549 1550 $this->foreign_content_stack[] = $token_name; 1551 1552 if ( 'math' === $namespace && 'ANNOTATION-XML' === $token_name ) { 1553 ++$this->math_annotation_xml_depth; 1554 } 1555 } 1556 } 1557 1558 if ( 'TEMPLATE' === $token_name && 'html' === $namespace && ! $is_closer ) { 1559 ++$template_depth; 1560 } 1561 1562 $skip_token = ( 1563 ( 1564 $template_depth > 0 && 1565 ! isset( $this->allowed_html['template'] ) 1566 ) || 1567 ( 1568 ! empty( $this->foreign_content_stack ) && 1569 ! isset( $this->allowed_html[ strtolower( $this->foreign_content_stack[0] ) ] ) 1570 ) 1571 ); 1572 1573 switch ( $token_type ) { 1574 case '#text': 1575 if ( $skip_token ) { 1576 break; 1577 } 1578 1579 $needs_special_newline = ( 1580 strlen( $output ) === $special_newline_at && 1581 1 === strspn( $text, "\n\r", 0, 1 ) 1582 ); 1583 1584 $text = strtr( 1585 $text, 1586 array( 1587 "\r" => '
', 1588 '<' => '<', 1589 '&' => '&', 1590 '>' => '>', 1591 ) 1592 ); 1593 1594 if ( $needs_special_newline ) { 1595 $output .= "\n{$text}"; 1596 } else { 1597 $output .= $text; 1598 } 1599 break; 1600 1601 /* 1602 * Untrusted sources should not be creating these kinds of tokens, 1603 * so remove them entirely from the output. 1604 */ 1605 case '#doctype': 1606 case '#presumptuous-tag': 1607 case '#processing-instruction': 1608 break; 1609 1610 /* 1611 * It’s questionable whether these should be allowed through, but 1612 * the legacy behavior supports it. Therefore, allow them as long 1613 * as they don’t contain potentially confusing syntax characters. 1614 */ 1615 case '#funky-comment': 1616 if ( ! $skip_token && ! str_contains( $text, '<' ) ) { 1617 $output .= substr( $this->html, $here->start, $here->length ); 1618 } 1619 break; 1620 1621 /* 1622 * `wp_kses()` runs iteratively on the content inside of these tokens, 1623 * but the content is benign in a browser. 1624 */ 1625 case '#comment': 1626 if ( $skip_token ) { 1627 break; 1628 } 1629 1630 /* 1631 * There are several kinds of malformed HTML which are handled by interpreting 1632 * them as HTML comments. For example, `<?>` is called a “bogus comment” by the 1633 * HTML specification, but when loaded by a browser is equivalent to `<!--?-->`. 1634 * In this way, interacting with the DOM via JavaScript differs from handling 1635 * the textual representation of a page in PHP. 1636 * 1637 * Ignore these non-normative comment forms to protect downstream parsers which 1638 * might not be expecting their kinds of syntax. This prevents mis-parses for 1639 * code which over-simplifies HTML parsing. 1640 */ 1641 if ( WP_HTML_Tag_Processor::COMMENT_AS_HTML_COMMENT !== $this->get_comment_type() ) { 1642 break; 1643 } 1644 1645 // Apply special filtering for block comment delimiters with JSON attributes. 1646 $comment = substr( $this->html, $here->start, $here->length ); 1647 1648 /* 1649 * A comment like `<!-- notes --!>` still appears as a normative HTML comment, 1650 * but as an incorrectly-closed comment. Ignore these as well, as part of only 1651 * allowing normative comment contents. 1652 */ 1653 $was_incorrectly_closed = '!' === $comment[ strlen( $comment ) - 2 ]; 1654 if ( $was_incorrectly_closed ) { 1655 break; 1656 } 1657 1658 $block_processor = new WP_Block_Processor( $comment ); 1659 if ( $block_processor->next_token() && ! $block_processor->is_html() ) { 1660 $block_type = $block_processor->get_block_type(); 1661 $implicit_block_type = str_starts_with( $block_type, 'core/' ) 1662 ? substr( $block_type, /* 'core/' */ 5 ) 1663 : $block_type; 1664 1665 switch ( $block_processor->get_delimiter_type() ) { 1666 // Track when blocks open and when they don’t self-close. 1667 case WP_Block_Processor::OPENER: 1668 $open_blocks[] = $implicit_block_type; 1669 $open_blocks_at[] = strlen( $output ); 1670 break; 1671 1672 // Track when blocks close. 1673 case WP_Block_Processor::CLOSER: 1674 if ( empty( $open_blocks ) ) { 1675 break 2; 1676 } 1677 1678 /* 1679 * The default parser closes any open block, even when 1680 * the names don’t match. Preserve this behavior here 1681 * to avoid differences in sanitization and parsing. 1682 */ 1683 $closed_block = array_pop( $open_blocks ); 1684 $closed_block_at = array_pop( $open_blocks_at ); 1685 1686 if ( 'html' !== $namespace && $closed_block_at < $foreign_content_starts_at ) { 1687 $foreign_closed_blocks[] = $closed_block; 1688 } 1689 } 1690 1691 // Filter block attributes for opening delimiters. 1692 if ( $block_processor->opens_block() ) { 1693 $original_attributes = $block_processor->allocate_and_return_parsed_attributes(); 1694 1695 if ( isset( $original_attributes ) ) { 1696 $filtered_attributes = filter_block_kses_value( 1697 $original_attributes, 1698 $this->specified_allowed_html, 1699 $this->allowed_protocols, 1700 array( 'blockName' => $block_type ) 1701 ); 1702 1703 if ( $original_attributes !== $filtered_attributes ) { 1704 $serialized_attributes = serialize_block_attributes( $filtered_attributes ); 1705 $voider = WP_Block_Processor::VOID === $block_processor->get_delimiter_type() ? '/' : ''; 1706 $text = " wp:{$implicit_block_type} {$serialized_attributes} {$voider}"; 1707 } 1708 } 1709 } 1710 } 1711 1712 /* 1713 * Legacy `wp_kses()` recursively calls itself on the contents of comments. 1714 * Since comment content is not escaped, this changes the meaning of those 1715 * comments when parsed. Still, code often expects to find tag-like syntax 1716 * only when they are real tags. This legacy defect is preserved to avoid 1717 * presenting content that downstream parsers might misinterpret as markup. 1718 */ 1719 $text = strtr( $text, array( '<' => '<' ) ); 1720 1721 $output .= "<!--{$text}-->"; 1722 break; 1723 1724 /* 1725 * True CDATA sections only exist within embedded SVG and MathML content, 1726 * where they represent text data without any escaping. However, because 1727 * parsers tend to vary on how to parse these, for untrusted inputs, 1728 * rewrite all CDATA sections as normal escaped text. 1729 */ 1730 case '#cdata-section': 1731 if ( ! $skip_token ) { 1732 $output .= strtr( 1733 $text, 1734 array( 1735 "\x00" => "\u{FFFD}", 1736 '<' => '<', 1737 '&' => '&', 1738 '>' => '>', 1739 ) 1740 ); 1741 } 1742 1743 break; 1744 1745 case '#tag': 1746 /* 1747 * Any failures inside foreign content should return the part of 1748 * the post processed up until the entrance of the foreign content. 1749 * This is necessary because it’s only inside foreign content that 1750 * the self-closing flag indicates a self-closing element. 1751 * 1752 * While the HTML Processor can enter into SVG and MATH and track 1753 * when they close, it’s substantially more complicated and requires 1754 * considerable accounting. To avoid all of that, and to accept the 1755 * kind of content that is nominal and safe, track only when the 1756 * next tag _could_ lead to implicit changing of the parsing namespace 1757 * or insertion mode. 1758 */ 1759 if ( 1760 'html' !== $namespace && 1761 $this->could_escape_foreign_content( 1762 $is_in_mathml_text_integration_point, 1763 $is_in_svg_html_integration_point 1764 ) 1765 ) { 1766 break 2; 1767 } 1768 1769 if ( $skip_token ) { 1770 break; 1771 } 1772 1773 $tag_name = strtolower( $token_name ); 1774 1775 // Skip unallowed elements by tag name 1776 if ( ! isset( $this->allowed_html[ $tag_name ] ) ) { 1777 break; 1778 } 1779 1780 if ( $is_closer ) { 1781 $output .= "</{$tag_name}>"; 1782 break; 1783 } 1784 1785 $is_special_atomic_element = ( 1786 'html' === $namespace && 1787 in_array( $token_name, $special_atomic_elements, true ) 1788 ); 1789 1790 $expects_closer = ! ( 1791 'html' === $namespace 1792 ? ( WP_HTML_Processor::is_void( $token_name ) || $is_special_atomic_element ) 1793 : $has_self_closing_flag 1794 ); 1795 1796 $self_closer = ( 'html' !== $namespace && $has_self_closing_flag ) ? ' /' : ''; 1797 $closing_tag = $is_special_atomic_element ? "</{$tag_name}>" : ''; 1798 1799 $attribute_names = $this->get_attribute_names_with_prefix( '' ); 1800 $element_attributes = $this->allowed_html[ $tag_name ]; 1801 1802 // Check for required attributes. 1803 $required_attributes = array(); 1804 if ( is_array( $element_attributes ) ) { 1805 foreach ( $element_attributes as $name => $spec ) { 1806 if ( true === ( $spec['required'] ?? false ) ) { 1807 $required_attributes[ $name ] = true; 1808 } 1809 } 1810 } 1811 1812 /* 1813 * Allow `data-*` attributes. 1814 * 1815 * When specifying `$allowed_html`, the attribute name should be set as 1816 * `data-*` (not to be mixed with the HTML 4.0 `data` attribute, see 1817 * https://www.w3.org/TR/html40/struct/objects.html#adef-data). 1818 * 1819 * Note: the attribute name should only contain `A-Za-z0-9_-` chars. 1820 */ 1821 if ( ! empty( $element_attributes['data-*'] ) ) { 1822 if ( is_array( $attribute_names ) ) { 1823 foreach ( $attribute_names as $name ) { 1824 if ( 1825 1 === preg_match( '/^data-[a-z0-9_-]+$/', $name ) && 1826 ( 1827 ! isset( $element_attributes[ $name ] ) || 1828 '' === $element_attributes[ $name ] 1829 ) 1830 ) { 1831 $element_attributes[ $name ] = $element_attributes['data-*']; 1832 } 1833 } 1834 } 1835 1836 unset( $element_attributes['data-*'] ); 1837 } 1838 1839 $tag_maker = new self( 1840 "<{$tag_name}{$self_closer}>{$closing_tag}", 1841 $this->specified_allowed_html, 1842 $this->allowed_html, 1843 $this->allowed_protocols, 1844 $this->uri_attributes 1845 ); 1846 $tag_maker->change_parsing_namespace( $namespace ); 1847 $tag_maker->next_token(); 1848 if ( is_array( $attribute_names ) ) { 1849 foreach ( $attribute_names as $name ) { 1850 $spec = $element_attributes[ $name ] ?? null; 1851 1852 // This attribute is not specified, thus not allowed. Skip it. 1853 if ( null === $spec || '' === $spec ) { 1854 continue; 1855 } 1856 1857 $raw_value = $this->get_attribute( $name ); 1858 $value = is_string( $raw_value ) ? $raw_value : ''; 1859 1860 // Process the style attribute through CSS sanitization. 1861 if ( 'style' === $name ) { 1862 if ( ! is_string( $raw_value ) ) { 1863 continue; 1864 } 1865 1866 $value = safecss_filter_attr( $value ); 1867 if ( '' === trim( $value ) ) { 1868 continue; 1869 } 1870 } 1871 1872 $is_url_ish = in_array( strtolower( $name ), $this->uri_attributes, true ); 1873 if ( $is_url_ish ) { 1874 $value = wp_kses_bad_protocol( $value, $this->allowed_protocols ); 1875 } 1876 1877 /* 1878 * Process the remaining attributes according to their policies. 1879 * 1880 * Non-array values for the attribute specification are assumed 1881 * to be `true`, thus permitting the attribute. 1882 */ 1883 if ( is_array( $spec ) ) { 1884 foreach ( $spec as $property => $constraint ) { 1885 $vless = true === $raw_value ? 'y' : 'n'; 1886 1887 if ( ! wp_kses_check_attr_val( $value, $vless, $property, $constraint ) ) { 1888 continue 2; 1889 } 1890 } 1891 } 1892 1893 $did_set = ( true === $raw_value && '' === $value ) 1894 ? $tag_maker->set_attribute( $name, true ) 1895 : $tag_maker->set_attribute( $name, $value ); 1896 1897 if ( $did_set ) { 1898 unset( $required_attributes[ $name ] ); 1899 } 1900 } 1901 } 1902 1903 $needs_special_newline = 'html' === $namespace && ( 'PRE' === $token_name || 'LISTING' === $token_name ); 1904 1905 if ( ! empty( $required_attributes ) ) { 1906 if ( ! $expects_closer ) { 1907 break; 1908 } 1909 1910 /* 1911 * Since this processor cannot track nesting of HTML elements 1912 * generally, leave opening tags when required attributes are 1913 * missing, but strip them of their attributes. 1914 */ 1915 $output .= "<{$tag_name}>"; 1916 if ( $needs_special_newline ) { 1917 $special_newline_at = strlen( $output ); 1918 } 1919 break; 1920 } 1921 1922 if ( $is_special_atomic_element ) { 1923 if ( 'TITLE' === $token_name || 'TEXTAREA' === $token_name ) { 1924 /* 1925 * RCDATA nodes can be safely escaped, but this must be 1926 * done after enqueing the update to avoid double-escaping. 1927 */ 1928 $tag_maker->set_modifiable_text( $text ); 1929 $tag_maker->lexical_updates['modifiable text']->text = strtr( 1930 $tag_maker->lexical_updates['modifiable text']->text, 1931 array( 1932 "\x00" => "\u{FFFD}", 1933 "\r" => '
', 1934 ) 1935 ); 1936 } elseif ( ! self::contains_a_block_delimiter( $text ) ) { 1937 // Other nodes not containing a block delimiter are safe. 1938 $tag_maker->set_modifiable_text( $text ); 1939 } else { 1940 /* 1941 * But RAWTEXT and SCRIPT cannot be generally escaped, so reject 1942 * updates which would include something that could be misparsed 1943 * as a block comment delimiter. 1944 */ 1945 $tag_maker->set_modifiable_text( '' ); 1946 } 1947 } 1948 1949 $output .= $tag_maker->get_updated_html(); 1950 if ( $needs_special_newline ) { 1951 $special_newline_at = strlen( $output ); 1952 } 1953 1954 break; 1955 } 1956 1957 // Re-enter the HTML namespace. 1958 if ( 'html' !== $namespace ) { 1959 if ( $has_self_closing_flag ) { 1960 array_pop( $this->foreign_content_stack ); 1961 1962 if ( 'math' === $namespace && 'ANNOTATION-XML' === $token_name ) { 1963 --$this->math_annotation_xml_depth; 1964 } 1965 } 1966 1967 if ( empty( $this->foreign_content_stack ) ) { 1968 $is_in_mathml_text_integration_point = false; 1969 $is_in_svg_html_integration_point = false; 1970 $this->change_parsing_namespace( 'html' ); 1971 $foreign_content_starts_at = PHP_INT_MAX; 1972 $foreign_closed_blocks = array(); 1973 } elseif ( '#tag' === $token_type && ! $has_self_closing_flag ) { 1974 switch ( $token_name ) { 1975 case 'MI': 1976 case 'MN': 1977 case 'MO': 1978 case 'MS': 1979 case 'MTEXT': 1980 $is_in_mathml_text_integration_point = ! $is_closer && 'math' === $namespace; 1981 break; 1982 1983 case 'DESC': 1984 case 'FOREIGNOBJECT': 1985 case 'TITLE': 1986 $is_in_svg_html_integration_point = ! $is_closer && 'svg' === $namespace; 1987 break; 1988 } 1989 } 1990 } 1991 1992 if ( 'TEMPLATE' === $token_name && $template_depth > 0 && $is_closer && 'html' === $namespace ) { 1993 --$template_depth; 1994 } 1995 } 1996 1997 /* 1998 * While there might have been an incomplete token in the output stream, 1999 * there is no need to render it to the output. They would disappear on 2000 * their own in a browser if they ended the document, but here they do 2001 * not end the document; instead, they are likely being inserted into an 2002 * existing document, where the incomplete token might mess with the rest 2003 * of the page’s HTML structure. 2004 */ 2005 2006 $sanitized = substr( $output, 0, $foreign_content_starts_at ); 2007 2008 // Templates should be contained within blocks, so close them first. 2009 if ( $template_depth > 0 && isset( $this->allowed_html['template'] ) ) { 2010 $sanitized .= str_repeat( '</template>', $template_depth ); 2011 } 2012 2013 // Close any remaining-open blocks ensure isolation of block content. 2014 foreach ( $foreign_closed_blocks as $block_name ) { 2015 $sanitized .= "<!-- /wp:{$block_name} -->"; 2016 } 2017 2018 for ( $i = count( $open_blocks ) - 1; $i >= 0; $i-- ) { 2019 // Skip blocks that were opened when inside truncated foreign content. 2020 if ( $open_blocks_at[ $i ] >= $foreign_content_starts_at ) { 2021 continue; 2022 } 2023 2024 $block_name = $open_blocks[ $i ]; 2025 $sanitized .= "<!-- /wp:{$block_name} -->"; 2026 } 2027 2028 return $sanitized; 2029 } 2030 }; 2031 2032 return $processor->sanitize(); 971 2033 } 972 2034 -
trunk/tests/phpunit/tests/admin/includesTemplate.php
r63943 r64233 351 351 'disallowed tag in before_section' => array( 352 352 array( 353 'before_section' => '<div class="video-settings-section"><iframe src="https://www.wordpress.org/" />',353 'before_section' => '<div class="video-settings-section"><iframe src="https://www.wordpress.org/"></iframe>', 354 354 'after_section' => '</div><!-- end of the test section -->', 355 355 ), … … 358 358 'title' => 'Section title', 359 359 'callback' => '__return_false', 360 'before_section' => '<div class="video-settings-section"><iframe src="https://www.wordpress.org/" />',360 'before_section' => '<div class="video-settings-section"><iframe src="https://www.wordpress.org/"></iframe>', 361 361 'after_section' => '</div><!-- end of the test section -->', 362 362 'section_class' => '', … … 368 368 array( 369 369 'before_section' => '<div class="video-settings-section">', 370 'after_section' => '</div><iframe src="https://www.wordpress.org/" />',370 'after_section' => '</div><iframe src="https://www.wordpress.org/"></iframe>', 371 371 ), 372 372 array( … … 375 375 'callback' => '__return_false', 376 376 'before_section' => '<div class="video-settings-section">', 377 'after_section' => '</div><iframe src="https://www.wordpress.org/" />',377 'after_section' => '</div><iframe src="https://www.wordpress.org/"></iframe>', 378 378 'section_class' => '', 379 379 ), -
trunk/tests/phpunit/tests/block-bindings/postMetaSource.php
r61605 r64233 261 261 $content = $this->get_modified_post_content( '<!-- wp:paragraph {"metadata":{"bindings":{"content":{"source":"core/post-meta","args":{"key":"tests_unsafe_html_field"}}}}} --><p>Fallback value</p><!-- /wp:paragraph -->' ); 262 262 263 $this->assertSame( 264 '<p class="wp-block-paragraph">alert(“Unsafe HTML”)</p>', 265 $content, 263 $this->assertEqualHTML( 264 '<p class="wp-block-paragraph"></p>', 265 $content, 266 '<body>', 266 267 'The post content should not include the script tag.' 267 268 ); -
trunk/tests/phpunit/tests/block-bindings/render.php
r64225 r64233 194 194 return '<script>alert("Unsafe HTML")</script>'; 195 195 }, 196 '<p class="wp-block-paragraph"> alert("Unsafe HTML")</p>',196 '<p class="wp-block-paragraph"></p>', 197 197 ), 198 198 'symbols and numbers should be rendered correctly' => array( … … 235 235 $result = $block->render(); 236 236 237 $this->assert Same(237 $this->assertEqualHTML( 238 238 $expected, 239 239 trim( $result ), 240 '<body>', 240 241 'The block content should be updated with the value returned by the source.' 241 242 ); -
trunk/tests/phpunit/tests/block-bindings/termDataSource.php
r64112 r64233 357 357 ); 358 358 359 $this->assert Same(360 '<p>Allowed HTML</p> alert("xss");& "quotes"',359 $this->assertEqualHTML( 360 '<p>Allowed HTML</p> & "quotes"', 361 361 _block_bindings_term_data_get_value( array( 'field' => 'description' ), $block ), 362 '<body>', 362 363 'Term description should be sanitized with wp_kses_post(), stripping disallowed tags like <script>.' 363 364 ); -
trunk/tests/phpunit/tests/customize/manager.php
r64116 r64233 1371 1371 // User saved as one who cannot bypass content_save_pre filter. 1372 1372 $this->assertStringNotContainsString( '<script>', get_option( 'custom_html_2' ) ); 1373 $this->assertString ContainsString( 'WordPress', get_option( 'custom_html_2' ) );1373 $this->assertStringNotContainsString( 'WordPress', get_option( 'custom_html_2' ) ); 1374 1374 1375 1375 // User saved as one who also cannot bypass content_save_pre filter. 1376 1376 $this->assertStringNotContainsString( '<script>', get_option( 'custom_html_3' ) ); 1377 $this->assertString ContainsString( 'WordPress', get_option( 'custom_html_3' ) );1377 $this->assertStringNotContainsString( 'WordPress', get_option( 'custom_html_3' ) ); 1378 1378 } 1379 1379 … … 2005 2005 do_action( 'customize_register', $wp_customize ); 2006 2006 $wp_customize->save_changeset_post( array( 'status' => 'publish' ) ); 2007 $this->assertSame( 'Unfiltered evil', get_option( 'scratchpad' ) );2007 $this->assertSame( 'Unfiltered', get_option( 'scratchpad' ) ); 2008 2008 2009 2009 // Attempt publishing scratchpad as anonymous user when changeset was set by privileged user. … … 2022 2022 $wp_customize = null; 2023 2023 unset( $GLOBALS['wp_actions']['customize_register'] ); 2024 $this->assertSame( 'Unfiltered evil', apply_filters( 'content_save_pre', 'Unfiltered<script>evil</script>' ) );2024 $this->assertSame( 'Unfiltered', apply_filters( 'content_save_pre', 'Unfiltered<script>evil</script>' ) ); 2025 2025 wp_publish_post( $changeset_post_id ); // @todo If wp_update_post() is used here, then kses will corrupt the post_content. 2026 2026 $this->assertSame( 'Unfiltered<script>evil</script>', get_option( 'scratchpad' ) ); -
trunk/tests/phpunit/tests/customize/nav-menu-item-setting.php
r63604 r64233 589 589 'position' => -123, 590 590 'type' => 'customb', 591 'title' => current_user_can( 'unfiltered_html' ) ? '\o/ o\'o Hi<script>unfilteredHtml()</script>' : '\o/ o\'o Hi unfilteredHtml()',591 'title' => current_user_can( 'unfiltered_html' ) ? '\o/ o\'o Hi<script>unfilteredHtml()</script>' : '\o/ o\'o Hi', 592 592 'url' => '', 593 593 'target' => 'onclick', 594 'attr_title' => current_user_can( 'unfiltered_html' ) ? '\o/ o\'o <b>bolded</b><script>unfilteredHtml()</script>' : '\o/ o\'o <b>bolded</b> unfilteredHtml()',595 'description' => current_user_can( 'unfiltered_html' ) ? '\o/ o\'o <b>Hello world</b><script>unfilteredHtml()</script>' : '\o/ o\'o <b>Hello world</b> unfilteredHtml()',594 'attr_title' => current_user_can( 'unfiltered_html' ) ? '\o/ o\'o <b>bolded</b><script>unfilteredHtml()</script>' : '\o/ o\'o <b>bolded</b>', 595 'description' => current_user_can( 'unfiltered_html' ) ? '\o/ o\'o <b>Hello world</b><script>unfilteredHtml()</script>' : '\o/ o\'o <b>Hello world</b>', 596 596 'classes' => 'hello inject', 597 597 'xfn' => 'hello inject', -
trunk/tests/phpunit/tests/formatting/sanitizeTextField.php
r57987 r64233 21 21 $expected_multiline = $expected; 22 22 } 23 $this->assert Same( $expected_oneline, sanitize_text_field( $str ) );23 $this->assertEqualHTML( $expected_oneline, sanitize_text_field( $str ) ); 24 24 $this->assertSameIgnoreEOL( $expected_multiline, sanitize_textarea_field( $str ) ); 25 25 } … … 56 56 "foo <\ndiv\n> bar", 57 57 array( 58 'oneline' => 'foo < div >bar',58 'oneline' => 'foo < div > bar', 59 59 'multiline' => "foo <\ndiv\n> bar", 60 60 ), -
trunk/tests/phpunit/tests/functions/wpTriggerError.php
r59107 r64233 111 111 'function_name' => 'some_function', 112 112 'message' => '<script>alert("expected the function name and message")</script>', 113 'expected_message' => 'some_function(): alert("expected the function name and message")',113 'expected_message' => 'some_function(): ', 114 114 ), 115 115 ); -
trunk/tests/phpunit/tests/icons/wpRestIconsController.php
r64224 r64233 376 376 $this->assertSame( 'Arrow Left', $data['label'] ); 377 377 $this->assertNotEmpty( $data['content'] ); 378 $this->assertStringStartsWith( 379 '<svg xmlns="',380 $data['content'],381 'Icon content should match the actual SVG asset'382 );378 379 $processor = new WP_HTML_Tag_Processor( $data['content'] ); 380 $this->assertTrue( $processor->next_token() ); 381 $this->assertSame( 'SVG', $processor->get_tag(), 'Icon content should match the actual SVG asset' ); 382 $this->assertSame( 'http://www.w3.org/2000/svg', $processor->get_attribute( 'xmlns' ), 'Icon content should match the actual SVG asset' ); 383 383 } 384 384 -
trunk/tests/phpunit/tests/kses.php
r64093 r64233 107 107 108 108 return $data; 109 } 110 111 /** 112 * Ensures that repeated runs return the same result. 113 * 114 * @ticket 65984 115 * 116 * @dataProvider data_wp_kses_idempotent_inputs 117 * 118 * @param string $input Process this HTML. 119 * @param array|null $allowed_html Optional. If provided, will be passed into `wp_kses()`. 120 * Default is to rely on the WordPress defaults. 121 * @param array|null $allowed_protocols Optional. If provided, will be passed into `wp_kses()`. 122 * Default is to rely on the WordPress defaults. 123 * @return void 124 */ 125 public function test_wp_kses_is_idempotent( string $input, ?array $allowed_html = null, ?array $allowed_protocols = null ): void { 126 $output = wp_kses( $input, $allowed_html, $allowed_protocols ); 127 128 $this->assertSame( 129 $output, 130 wp_kses( $output, $allowed_html, $allowed_protocols ), 131 'Should have produced the same output after running the given input back through `wp_kses()`' 132 ); 133 } 134 135 /** 136 * Data provider. 137 * 138 * @return array[] 139 */ 140 public static function data_wp_kses_idempotent_inputs(): array { 141 return array( 142 array( 143 '<div>a < b</div>', 144 ), 145 array( 146 '<div id="a < b">', 147 array( 148 'div' => array( 149 'id' => true, 150 ), 151 ), 152 ), 153 ); 109 154 } 110 155 … … 365 410 switch ( $attack->name ) { 366 411 case 'XSS Locator': 367 $this->assert Same( '\';alert(String.fromCharCode(88,83,83))//\\\';alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//\\";alert(String.fromCharCode(88,83,83))//-->">\'>alert(String.fromCharCode(88,83,83))=&{}', $result );412 $this->assertEqualHTML( '\';alert(String.fromCharCode(88,83,83))//\\\';alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//\\";alert(String.fromCharCode(88,83,83))//-->">\'>=&{}', $result ); 368 413 break; 369 414 case 'XSS Quick Test': 370 $this->assert Same( '\'\';!--"=&{()}', $result );415 $this->assertEqualHTML( '\'\';!--"=&{()}', $result ); 371 416 break; 372 417 case 'SCRIPT w/Alert()': 373 $this->assert Same( "alert('XSS')", $result );418 $this->assertEqualHTML( "alert('XSS')", $result ); 374 419 break; 375 420 case 'SCRIPT w/Char Code': 376 $this->assert Same( 'alert(String.fromCharCode(88,83,83))', $result );421 $this->assertEqualHTML( 'alert(String.fromCharCode(88,83,83))', $result ); 377 422 break; 378 423 case 'IMG STYLE w/expression': 379 $this->assert Same( 'exp/*', $result );424 $this->assertEqualHTML( 'exp/*', $result ); 380 425 break; 381 426 case 'List-style-image': 382 $this->assert Same( 'li {list-style-image: url("javascript:alert(\'XSS\')");}XSS', $result );427 $this->assertEqualHTML( 'li {list-style-image: url("javascript:alert(\'XSS\')");}XSS', $result ); 383 428 break; 384 429 case 'STYLE': 385 $this->assert Same( "alert('XSS');", $result );430 $this->assertEqualHTML( "alert('XSS');", $result ); 386 431 break; 387 432 case 'STYLE w/background-image': 388 $this->assert Same( '.XSS{background-image:url("javascript:alert(\'XSS\')");}<A></A>', $result );433 $this->assertEqualHTML( '<A></A>', $result ); 389 434 break; 390 435 case 'STYLE w/background': 391 $this->assert Same( 'BODY{background:url("javascript:alert(\'XSS\')")}', $result );436 $this->assertEqualHTML( 'BODY{background:url("javascript:alert(\'XSS\')")}', $result ); 392 437 break; 393 438 case 'Remote Stylesheet 2': 394 $this->assert Same( "@import'http://ha.ckers.org/xss.css';", $result );439 $this->assertEqualHTML( "@import'http://ha.ckers.org/xss.css';", $result ); 395 440 break; 396 441 case 'Remote Stylesheet 3': 397 $this->assert Same( '<META HTTP-EQUIV="Link" Content="; REL=stylesheet">', $result );442 $this->assertEqualHTML( '<META HTTP-EQUIV="Link" Content="; REL=stylesheet">', $result ); 398 443 break; 399 444 case 'Remote Stylesheet 4': 400 $this->assert Same( 'BODY{-moz-binding:url("http://ha.ckers.org/xssmoz.xml#xss")}', $result );445 $this->assertEqualHTML( 'BODY{-moz-binding:url("http://ha.ckers.org/xssmoz.xml#xss")}', $result ); 401 446 break; 402 447 case 'XML data island w/CDATA': 403 $this->assert Same( '<![CDATA[]]>', $result );448 $this->assertEqualHTML( ']]>', $result ); 404 449 break; 405 450 case 'XML data island w/comment': 406 $this->assert Same( "<I><B><IMG SRC="javas<!-- -->cript:alert('XSS')\"></B></I>", $result );451 $this->assertEqualHTML( '<I><B></B></I>', $result ); 407 452 break; 408 453 case 'XML HTML+TIME': 409 $this->assert Same( '<t:set attributeName="innerHTML" to="XSSalert(\'XSS\')">', $result );454 $this->assertEqualHTML( '', $result ); 410 455 break; 411 456 case 'Commented-out Block': 412 $this->assert Same( "<!--[if gte IE 4]>-->\nalert('XSS');", $result );457 $this->assertEqualHTML( "<!--[if gte IE 4]>\n<SCRIPT>alert('XSS');</SCRIPT>\n<![endif]-->", $result ); 413 458 break; 414 459 case 'Cookie Manipulation': 415 $this->assert Same( '<META HTTP-EQUIV="Set-Cookie" Content="USERID=alert(\'XSS\')">', $result );460 $this->assertEqualHTML( '<META HTTP-EQUIV="Set-Cookie" Content="USERID=alert(\'XSS\')">', $result ); 416 461 break; 417 462 case 'SSI': 418 $this->assert Same( '<!--#exec cmd="/bin/echo '<!--#exec cmd="/bin/echo \'=http://ha.ckers.org/xss.js>\'"-->', $result );463 $this->assertEqualHTML( '<!--#exec cmd="/bin/echo \'<SCRIPT SRC\'"--><!--#exec cmd="/bin/echo \'=http://ha.ckers.org/xss.js></SCRIPT>\'"-->', $result ); 419 464 break; 420 465 case 'PHP': 421 $this->assert Same( '<? echo('alert("XSS")\'); ?>', $result );466 $this->assertEqualHTML( 'alert("XSS")\'); ?>', $result ); 422 467 break; 423 468 case 'UTF-7 Encoding': 424 $this->assert Same( '+ADw-SCRIPT+AD4-alert(\'XSS\');+ADw-/SCRIPT+AD4-', $result );469 $this->assertEqualHTML( '+ADw-SCRIPT+AD4-alert(\'XSS\');+ADw-/SCRIPT+AD4-', $result ); 425 470 break; 426 471 case 'Escaping JavaScript escapes': 427 $this->assert Same( '\";alert(\'XSS\');//', $result );472 $this->assertEqualHTML( '\";alert(\'XSS\');//', $result ); 428 473 break; 429 474 case 'STYLE w/broken up JavaScript': 430 $this->assert Same( '@im\port\'\ja\vasc\ript:alert("XSS")\';', $result );475 $this->assertEqualHTML( '@im\port\'\ja\vasc\ript:alert("XSS")\';', $result ); 431 476 break; 432 477 case 'Null Chars 2': 433 $this->assert Same( '&alert("XSS")', $result );478 $this->assertEqualHTML( '&alert("XSS")', $result ); 434 479 break; 435 480 case 'No Closing Script Tag': 436 $this->assert Same( '<SCRIPT SRC=http://ha.ckers.org/xss.js', $result );481 $this->assertEqualHTML( '<SCRIPT SRC=http://ha.ckers.org/xss.js', $result ); 437 482 break; 438 483 case 'Half-Open HTML/JavaScript': 439 $this->assert Same( '<IMG SRC="javascript:alert('XSS')"', $result );484 $this->assertEqualHTML( '<IMG SRC="javascript:alert('XSS')"', $result ); 440 485 break; 441 486 case 'Double open angle brackets': 442 $this->assert Same( '<IFRAME SRC=http://ha.ckers.org/scriptlet.html <', $result );487 $this->assertEqualHTML( '<IFRAME SRC=http://ha.ckers.org/scriptlet.html <', $result ); 443 488 break; 444 489 case 'Extraneous Open Brackets': 445 $this->assertSame( '< alert("XSS");//<', $result );490 $this->assertSame( '<', $result ); 446 491 break; 447 492 case 'Malformed IMG Tags': 448 $this->assert Same( 'alert("XSS")">', $result );493 $this->assertEqualHTML( '">', $result ); 449 494 break; 450 495 case 'No Quotes/Semicolons': 451 $this->assert Same( "a=/XSS/\nalert(a.source)", $result );496 $this->assertEqualHTML( "a=/XSS/\nalert(a.source)", $result ); 452 497 break; 453 498 case 'Evade Regex Filter 1': 454 $this->assert Same( '" SRC="http://ha.ckers.org/xss.js">', $result );499 $this->assertEqualHTML( '" SRC="http://ha.ckers.org/xss.js">', $result ); 455 500 break; 456 501 case 'Evade Regex Filter 4': 457 $this->assert Same( '\'" SRC="http://ha.ckers.org/xss.js">', $result );502 $this->assertEqualHTML( '\'" SRC="http://ha.ckers.org/xss.js">', $result ); 458 503 break; 459 504 case 'Evade Regex Filter 5': 460 $this->assert Same( '` SRC="http://ha.ckers.org/xss.js">', $result );505 $this->assertEqualHTML( '` SRC="http://ha.ckers.org/xss.js">', $result ); 461 506 break; 462 507 case 'Filter Evasion 1': 463 $this->assert Same( 'document.write("<SCRI");PT SRC="http://ha.ckers.org/xss.js">', $result );508 $this->assertEqualHTML( 'PT SRC="http://ha.ckers.org/xss.js">', $result ); 464 509 break; 465 510 case 'Filter Evasion 2': 466 $this->assert Same( '\'>" SRC="http://ha.ckers.org/xss.js">', $result );511 $this->assertEqualHTML( '\'>" SRC="http://ha.ckers.org/xss.js">', $result ); 467 512 break; 468 513 default: … … 855 900 global $allowedposttags; 856 901 857 return $this->assertEqualHTML( $expected, wp_kses( $content, $allowedposttags ) ); 902 // It also must explicitly escape the C0 control characters. 903 $this->assertSame( $expected, wp_kses( $content, $allowedposttags ) ); 858 904 } 859 905 … … 876 922 'hello world. WORDPRESS KSES./', 877 923 ), 924 /* 925 * When decoding HTML, all "\r\n" grapheme clusters are converted into "\n" and 926 * then any remaining "\r" characters are also converted into "\n". This is why 927 * the two yield different outputs after normalization depending on the order in 928 * which they appear together. 929 */ 878 930 array( 879 931 "\t\r\n word \n\r\t", 880 "\t\ r\n word \n\r\t",932 "\t\n word \n\n\t", 881 933 ), 882 934 ); … … 892 944 global $allowedposttags; 893 945 894 return $this->assertEqualHTML( $expected, wp_kses( $content, $allowedposttags ) ); 946 $with_style = array_merge( 947 $allowedposttags, 948 array( 949 'style' => array( 950 'type' => true, 951 ), 952 ) 953 ); 954 955 return $this->assertEqualHTML( $expected, wp_kses( $content, $with_style ) ); 895 956 } 896 957 … … 931 992 array( 932 993 '<style type="text/css">div {background-image:\\0}</style>', 933 ' div {background-image:\\0}',994 '<style type="text/css">div {background-image:\\0}</style>', 934 995 ), 935 996 ); … … 2371 2432 'invalid value for type' => array( 2372 2433 '<object type="application/exe" data="https://' . WP_TESTS_DOMAIN . '/foo.exe" />', 2373 ' ',2434 '<object>', 2374 2435 ), 2375 2436 'multiple type attributes, last invalid' => array( … … 2387 2448 'multiple type attributes, first invalid' => array( 2388 2449 '<object type="application/exe" type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 2389 ' ',2450 '<object>', 2390 2451 ), 2391 2452 'multiple type attributes, first upper case and invalid' => array( 2392 2453 '<object TYPE="application/exe" type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 2393 ' ',2454 '<object>', 2394 2455 ), 2395 2456 'multiple type attributes, first invalid, last uppercase' => array( 2396 2457 '<object type="application/exe" TYPE="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 2397 ' ',2458 '<object>', 2398 2459 ), 2399 2460 'multiple object tags, last invalid' => array( 2400 2461 '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" /><object type="application/exe" data="https://' . WP_TESTS_DOMAIN . '/foo.exe" />', 2401 '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" /> ',2462 '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" /><object>', 2402 2463 ), 2403 2464 'multiple object tags, first invalid' => array( 2404 2465 '<object type="application/exe" data="https://' . WP_TESTS_DOMAIN . '/foo.exe" /><object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 2405 '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />',2466 '<object><object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 2406 2467 ), 2407 2468 'type attribute with partially incorrect value' => array( 2408 2469 '<object type="application/pdfa" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 2409 ' ',2470 '<object>', 2410 2471 ), 2411 2472 'type attribute with empty value' => array( 2412 2473 '<object type="" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 2413 ' ',2474 '<object>', 2414 2475 ), 2415 2476 'type attribute with no value' => array( 2416 2477 '<object type data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 2417 ' ',2478 '<object>', 2418 2479 ), 2419 2480 'no type attribute' => array( 2420 2481 '<object data="https://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 2421 ' ',2482 '<object>', 2422 2483 ), 2423 2484 'different protocol in url' => array( … … 2427 2488 'query string on url' => array( 2428 2489 '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf?lol=.pdf" />', 2429 ' ',2490 '<object>', 2430 2491 ), 2431 2492 'fragment on url' => array( 2432 2493 '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.pdf#lol.pdf" />', 2433 ' ',2494 '<object>', 2434 2495 ), 2435 2496 'wrong extension' => array( 2436 2497 '<object type="application/pdf" data="https://' . WP_TESTS_DOMAIN . '/foo.php" />', 2437 ' ',2498 '<object>', 2438 2499 ), 2439 2500 'protocol-relative url' => array( 2440 2501 '<object type="application/pdf" data="//' . WP_TESTS_DOMAIN . '/foo.pdf" />', 2441 ' ',2502 '<object>', 2442 2503 ), 2443 2504 'unsupported protocol' => array( 2444 2505 '<object type="application/pdf" data="ftp://' . WP_TESTS_DOMAIN . '/foo.pdf" />', 2445 ' ',2506 '<object>', 2446 2507 ), 2447 2508 'relative url' => array( 2448 2509 '<object type="application/pdf" data="/cat/foo.pdf" />', 2449 ' ',2510 '<object>', 2450 2511 ), 2451 2512 'url with port number-like path' => array( … … 2486 2547 'url with wrong port number' => array( 2487 2548 '<object type="application/pdf" data="http://example.org:3333/cat/foo.pdf" />', 2488 ' ',2549 '<object>', 2489 2550 ), 2490 2551 'url without port number' => array( 2491 2552 '<object type="application/pdf" data="http://example.org/cat/foo.pdf" />', 2492 ' ',2553 '<object>', 2493 2554 ), 2494 2555 ); … … 2554 2615 2555 2616 /** 2556 * Ensures that `wp_kses()` preserves various kinds of HTML comments, both valid and invalid. 2617 * Ensures that `wp_kses()` preserves various kinds of HTML comments; 2618 * specifically well-formed comments and “funky comments.” 2557 2619 * 2558 2620 * @ticket 61009 … … 2582 2644 'Normative HTML comment' => array( 'before<!-- this is a comment -->after', 'before<!-- this is a comment -->after' ), 2583 2645 'Closing tag with invalid tag name' => array( 'before<//not a tag>after', 'before<//not a tag>after' ), 2584 'Incorrectly opened comment (Markup declaration)' => array( 'before<!also not a tag>after', 'before <!also not a tag>after' ),2646 'Incorrectly opened comment (Markup declaration)' => array( 'before<!also not a tag>after', 'beforeafter' ), 2585 2647 ); 2586 2648 } -
trunk/tests/phpunit/tests/link/getThePrivacyPolicyLink.php
r64092 r64233 110 110 111 111 $this->assertStringEndsWith( 112 '><strong class="privacy">Privacy</strong> <em class="policy">Policy</em> <b class="bold">Bold</b> <i class="italic">Italic</i> <span class="page-title">Page</span> alert("test")</a>',112 '><strong class="privacy">Privacy</strong> <em class="policy">Policy</em> <b class="bold">Bold</b> <i class="italic">Italic</i> <span class="page-title">Page</span> </a>', 113 113 $actual_link 114 114 ); -
trunk/tests/phpunit/tests/media.php
r64059 r64233 4738 4738 4739 4739 $html = get_the_block_template_html(); 4740 $this->assert Same( '<div class="wp-site-blocks"><div class="entry-content wp-block-post-content is-layout-flow wp-block-post-content-is-layout-flow">' . $expected_content . '</div></div>', $html );4740 $this->assertEqualHTML( '<div class="wp-site-blocks"><div class="entry-content wp-block-post-content is-layout-flow wp-block-post-content-is-layout-flow">' . $expected_content . '</div></div>', $html ); 4741 4741 } 4742 4742 … … 4808 4808 4809 4809 $html = get_the_block_template_html(); 4810 $this->assert Same( '<div class="wp-site-blocks">' . $expected_featured_image . ' <div class="entry-content wp-block-post-content is-layout-flow wp-block-post-content-is-layout-flow">' . $expected_content . '</div></div>', $html );4810 $this->assertEqualHTML( '<div class="wp-site-blocks">' . $expected_featured_image . ' <div class="entry-content wp-block-post-content is-layout-flow wp-block-post-content-is-layout-flow">' . $expected_content . '</div></div>', $html ); 4811 4811 } 4812 4812 … … 4867 4867 4868 4868 $html = get_the_block_template_html(); 4869 $this->assert Same( '<div class="wp-site-blocks">' . $expected_template_content . '</div>', $html );4869 $this->assertEqualHTML( '<div class="wp-site-blocks">' . $expected_template_content . '</div>', $html ); 4870 4870 } 4871 4871 … … 5980 5980 remove_shortcode( 'full_image' ); 5981 5981 5982 $this->assert Same( $expected_content, $content );5982 $this->assertEqualHTML( $expected_content, $content ); 5983 5983 } 5984 5984 … … 6134 6134 unregister_block_type( 'core/full-image-shortcode' ); 6135 6135 6136 $this->assert Same( $expected_content, $content );6136 $this->assertEqualHTML( $expected_content, $content ); 6137 6137 } 6138 6138 -
trunk/tests/phpunit/tests/post/output.php
r61605 r64233 148 148 $this->assertNull( the_post() ); 149 149 150 $this->assert Same( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) );150 $this->assertEqualHTML( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) ); 151 151 152 152 kses_remove_filters(); -
trunk/tests/phpunit/tests/post/wpPublishPost.php
r54090 r64233 89 89 $post_id = wp_insert_post( 90 90 array( 91 'post_title' => ' <script>Test</script>',91 'post_title' => 'Talking about: <script>Test</script>', 92 92 ) 93 93 ); 94 94 $post = get_post( $post_id ); 95 $this->assertSame( ' <script>Test</script>', $post->post_title );95 $this->assertSame( 'Talking about: <script>Test</script>', $post->post_title ); 96 96 $this->assertSame( 'draft', $post->post_status ); 97 97 … … 108 108 109 109 $post = get_post( $post->ID ); 110 $this->assertSame( 'T est', $post->post_title );110 $this->assertSame( 'Talking about: ', $post->post_title ); 111 111 } 112 112 -
trunk/tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportGroupHtml.php
r58164 r64233 175 175 'scripts' => array( 176 176 'name' => 'Script tags are not allowed.', 177 'value' => ' <script>Testing that script tags are stripped.</script>',177 'value' => 'Before<script>Testing that script tags are stripped.</script>After', 178 178 ), 179 179 'images' => array( … … 188 188 189 189 $this->assertStringNotContainsString( $data['items'][0]['scripts']['value'], $actual ); 190 $this->assertStringContainsString( '<td> Testing that script tags are stripped.</td>', $actual );190 $this->assertStringContainsString( '<td>BeforeAfter</td>', $actual ); 191 191 192 192 $this->assertStringNotContainsString( $data['items'][0]['images']['value'], $actual ); -
trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php
r64118 r64233 1853 1853 array( 1854 1854 'title' => array( 1855 'raw' => 'div <strong>strong</strong> oh noes',1856 'rendered' => 'div <strong>strong</strong> oh noes',1855 'raw' => 'div <strong>strong</strong> ', 1856 'rendered' => 'div <strong>strong</strong>', 1857 1857 ), 1858 1858 'description' => array( 1859 'raw' => '<div>div</div> <strong>strong</strong> oh noes',1860 'rendered' => "<div>div</div>\n<p> <strong>strong</strong> oh noes</p>",1859 'raw' => '<div>div</div> <strong>strong</strong> ', 1860 'rendered' => "<div>div</div>\n<p> <strong>strong</strong> </p>", 1861 1861 ), 1862 1862 'caption' => array( 1863 'raw' => '<div>div</div> <strong>strong</strong> oh noes',1864 'rendered' => "<div>div</div>\n<p> <strong>strong</strong> oh noes</p>",1863 'raw' => '<div>div</div> <strong>strong</strong> ', 1864 'rendered' => "<div>div</div>\n<p> <strong>strong</strong> </p>", 1865 1865 ), 1866 1866 ), … … 1907 1907 array( 1908 1908 'title' => array( 1909 'raw' => 'div <strong>strong</strong> oh noes',1910 'rendered' => 'div <strong>strong</strong> oh noes',1909 'raw' => 'div <strong>strong</strong> ', 1910 'rendered' => 'div <strong>strong</strong>', 1911 1911 ), 1912 1912 'description' => array( 1913 'raw' => '<div>div</div> <strong>strong</strong> oh noes',1914 'rendered' => "<div>div</div>\n<p> <strong>strong</strong> oh noes</p>",1913 'raw' => '<div>div</div> <strong>strong</strong> ', 1914 'rendered' => "<div>div</div>\n<p> <strong>strong</strong> </p>", 1915 1915 ), 1916 1916 'caption' => array( 1917 'raw' => '<div>div</div> <strong>strong</strong> oh noes',1918 'rendered' => "<div>div</div>\n<p> <strong>strong</strong> oh noes</p>",1917 'raw' => '<div>div</div> <strong>strong</strong> ', 1918 'rendered' => "<div>div</div>\n<p> <strong>strong</strong> </p>", 1919 1919 ), 1920 1920 ) -
trunk/tests/phpunit/tests/rest-api/rest-comments-controller.php
r63912 r64233 3148 3148 array( 3149 3149 'content' => array( 3150 'raw' => 'div <strong>strong</strong> oh noes',3151 'rendered' => '<p>div <strong>strong</strong> oh noes</p>',3150 'raw' => 'div <strong>strong</strong> ', 3151 'rendered' => '<p>div <strong>strong</strong> </p>', 3152 3152 ), 3153 3153 'author_name' => 'div strong', -
trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php
r64039 r64233 4667 4667 array( 4668 4668 'title' => array( 4669 'raw' => 'div <strong>strong</strong> oh noes',4670 'rendered' => 'div <strong>strong</strong> oh noes',4669 'raw' => 'div <strong>strong</strong> ', 4670 'rendered' => 'div <strong>strong</strong>', 4671 4671 ), 4672 4672 'content' => array( 4673 'raw' => '<div>div</div> <strong>strong</strong> oh noes',4674 'rendered' => "<div>div</div>\n<p> <strong>strong</strong> oh noes</p>",4673 'raw' => '<div>div</div> <strong>strong</strong> ', 4674 'rendered' => "<div>div</div>\n<p> <strong>strong</strong> </p>", 4675 4675 ), 4676 4676 'excerpt' => array( 4677 'raw' => '<div>div</div> <strong>strong</strong> oh noes',4678 'rendered' => "<div>div</div>\n<p> <strong>strong</strong> oh noes</p>",4677 'raw' => '<div>div</div> <strong>strong</strong> ', 4678 'rendered' => "<div>div</div>\n<p> <strong>strong</strong> </p>", 4679 4679 ), 4680 4680 ), … … 4719 4719 array( 4720 4720 'title' => array( 4721 'raw' => 'div <strong>strong</strong> oh noes',4722 'rendered' => 'div <strong>strong</strong> oh noes',4721 'raw' => 'div <strong>strong</strong> ', 4722 'rendered' => 'div <strong>strong</strong>', 4723 4723 ), 4724 4724 'content' => array( 4725 'raw' => '<div>div</div> <strong>strong</strong> oh noes',4726 'rendered' => "<div>div</div>\n<p> <strong>strong</strong> oh noes</p>",4725 'raw' => '<div>div</div> <strong>strong</strong> ', 4726 'rendered' => "<div>div</div>\n<p> <strong>strong</strong> </p>", 4727 4727 ), 4728 4728 'excerpt' => array( 4729 'raw' => '<div>div</div> <strong>strong</strong> oh noes',4730 'rendered' => "<div>div</div>\n<p> <strong>strong</strong> oh noes</p>",4729 'raw' => '<div>div</div> <strong>strong</strong> ', 4730 'rendered' => "<div>div</div>\n<p> <strong>strong</strong> </p>", 4731 4731 ), 4732 4732 ) -
trunk/tests/phpunit/tests/rest-api/rest-tags-controller.php
r63616 r64233 1105 1105 array( 1106 1106 'name' => 'div strong', 1107 'description' => 'div <strong>strong</strong> oh noes',1107 'description' => 'div <strong>strong</strong> ', 1108 1108 ) 1109 1109 ); … … 1117 1117 array( 1118 1118 'name' => 'div strong', 1119 'description' => 'div <strong>strong</strong> oh noes',1119 'description' => 'div <strong>strong</strong> ', 1120 1120 ) 1121 1121 ); … … 1150 1150 array( 1151 1151 'name' => 'div strong', 1152 'description' => 'div <strong>strong</strong> oh noes',1152 'description' => 'div <strong>strong</strong> ', 1153 1153 ) 1154 1154 ); -
trunk/tests/phpunit/tests/rest-api/rest-users-controller.php
r64070 r64233 2389 2389 'last_name' => 'div strong', 2390 2390 'url' => 'http://divdiv/div%20strongstrong/strong%20scriptoh%20noes/script', 2391 'description' => 'div <strong>strong</strong> oh noes',2391 'description' => 'div <strong>strong</strong> ', 2392 2392 'nickname' => 'div strong', 2393 2393 'password' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', … … 2412 2412 'last_name' => 'div strong', 2413 2413 'url' => 'http://divdiv/div%20strongstrong/strong%20scriptoh%20noes/script', 2414 'description' => 'div <strong>strong</strong> oh noes',2414 'description' => 'div <strong>strong</strong> ', 2415 2415 'nickname' => 'div strong', 2416 2416 'password' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', … … 2471 2471 'last_name' => 'div strong', 2472 2472 'url' => 'http://divdiv/div%20strongstrong/strong%20scriptoh%20noes/script', 2473 'description' => 'div <strong>strong</strong> oh noes',2473 'description' => 'div <strong>strong</strong> ', 2474 2474 'nickname' => 'div strong', 2475 2475 'password' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', -
trunk/tests/phpunit/tests/rest-api/rest-widgets-controller.php
r64074 r64233 1280 1280 if ( is_multisite() ) { 1281 1281 $this->assertSame( 1282 '<div class="textwidget"> alert(1)</div>',1282 '<div class="textwidget"></div>', 1283 1283 $this->update_text_widget_with_raw_html( '<script>alert(1)</script>' ) 1284 1284 ); -
trunk/tests/phpunit/tests/rest-api/wpRestUrlDetailsController.php
r64077 r64233 756 756 $method = $this->get_reflective_method( 'get_description' ); 757 757 $actual = $method->invoke( $controller, $meta_elements ); 758 $this->assert Same( $expected, $actual );758 $this->assertEqualHTML( $expected, $actual ); 759 759 } 760 760 -
trunk/tests/phpunit/tests/widgets/wpWidgetMediaImage.php
r59120 r64233 242 242 $result, 243 243 array( 244 'caption' => '"><i />',245 ) 244 'caption' => '"><i>', 245 ), 246 246 ); 247 247
Note:
See TracChangeset
for help on using the changeset viewer.