Changeset 50923
- Timestamp:
- 05/17/2021 09:03:56 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/kses.php
r50922 r50923 2173 2173 * @since 5.3.1 Added support for gradient backgrounds. 2174 2174 * @since 5.7.1 Added support for `object-position`. 2175 * @since 5.8.0 Added support for `calc()` and `var()` values. 2175 2176 * 2176 2177 * @param string[] $attr Array of allowed CSS attributes. … … 2382 2383 2383 2384 if ( $found ) { 2384 // Check for any CSS containing \ ( & } = or comments, except for url() usage checked above. 2385 // Allow CSS calc(). 2386 $css_test_string = preg_replace( '/calc\(((?:\([^()]*\)?|[^()])*)\)/', '', $css_test_string ); 2387 // Allow CSS var(). 2388 $css_test_string = preg_replace( '/\(?var\(--[a-zA-Z0-9_-]*\)/', '', $css_test_string ); 2389 2390 // Check for any CSS containing \ ( & } = or comments, 2391 // except for url(), calc(), or var() usage checked above. 2385 2392 $allow_css = ! preg_match( '%[\\\(&=}]|/\*%', $css_test_string ); 2386 2393 -
trunk/tests/phpunit/tests/kses.php
r49697 r50923 1213 1213 * 1214 1214 * @ticket 45067 1215 * @ticket 46197 1216 * @ticket 46498 1215 1217 * 1216 1218 * @param $input string The style attribute saved in the editor. … … 1288 1290 ), 1289 1291 1292 // CSS calc(). 1293 array( 1294 'width: calc(2em + 3px)', 1295 'width: calc(2em + 3px)', 1296 ), 1297 1298 // CSS variable. 1299 array( 1300 'padding: var(--wp-var1) var(--wp-var2)', 1301 'padding: var(--wp-var1) var(--wp-var2)', 1302 ), 1303 1304 // CSS calc() with var(). 1305 array( 1306 'margin-top: calc(var(--wp-var1) * 3 + 2em)', 1307 'margin-top: calc(var(--wp-var1) * 3 + 2em)', 1308 ), 1309 1290 1310 /* 1291 1311 * Invalid use cases. … … 1349 1369 array( 1350 1370 'background-image: url( "http://example.com );', 1371 '', 1372 ), 1373 1374 // Malformed calc, no closing `)`. 1375 array( 1376 'width: calc(3em + 10px', 1377 '', 1378 ), 1379 1380 // Malformed var, no closing `)`. 1381 array( 1382 'width: var(--wp-var1', 1351 1383 '', 1352 1384 ),
Note: See TracChangeset
for help on using the changeset viewer.