Changeset 58294
- Timestamp:
- 06/03/2024 01:24:25 PM (4 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/kses.php
r58196 r58294 1264 1264 * https://www.w3.org/TR/html40/struct/objects.html#adef-data). 1265 1265 * 1266 * Note: the attribute name should only contain `A-Za-z0-9_-` chars, 1267 * double hyphens `--` are not accepted by WordPress. 1266 * Note: the attribute name should only contain `A-Za-z0-9_-` chars. 1268 1267 */ 1269 1268 if ( str_starts_with( $name_low, 'data-' ) && ! empty( $allowed_attr['data-*'] ) 1270 && preg_match( '/^data (?:-[a-z0-9_]+)+$/', $name_low, $match )1269 && preg_match( '/^data-[a-z0-9_-]+$/', $name_low, $match ) 1271 1270 ) { 1272 1271 /* -
trunk/tests/phpunit/tests/kses.php
r58097 r58294 1363 1363 */ 1364 1364 public function test_wp_kses_attr_data_attribute_is_allowed() { 1365 $test = '<div data-foo="foo" data-bar="bar" datainvalid="gone" data- -invalid="gone" data-also-invalid-="gone" data-two-hyphens="remains">Pens and pencils</div>';1365 $test = '<div data-foo="foo" data-bar="bar" datainvalid="gone" data-two-hyphens="remains">Pens and pencils</div>'; 1366 1366 $expected = '<div data-foo="foo" data-bar="bar" data-two-hyphens="remains">Pens and pencils</div>'; 1367 1368 $this->assertSame( $expected, wp_kses_post( $test ) ); 1369 } 1370 1371 /** 1372 * Data attributes with leading, trailing, and double "-" are globally accepted. 1373 * 1374 * @ticket 61052 1375 */ 1376 public function test_wp_kses_attr_data_attribute_hypens_allowed() { 1377 $test = '<div data--leading="remains" data-trailing-="remains" data-middle--double="remains">Pens and pencils</div>'; 1378 $expected = '<div data--leading="remains" data-trailing-="remains" data-middle--double="remains">Pens and pencils</div>'; 1367 1379 1368 1380 $this->assertSame( $expected, wp_kses_post( $test ) );
Note: See TracChangeset
for help on using the changeset viewer.