Ticket #48376: 48376.diff
File 48376.diff, 4.4 KB (added by , 5 years ago) |
---|
-
src/wp-includes/kses.php
2209 2209 'list-style-image', 2210 2210 ); 2211 2211 2212 /* 2213 * CSS attributes where we accept gradient data types. 2214 * 2215 */ 2216 $css_gradient_data_types = array( 2217 'background', 2218 'background-image', 2219 ); 2220 2212 2221 if ( empty( $allowed_attr ) ) { 2213 2222 return $css; 2214 2223 } … … 2223 2232 $css_test_string = $css_item; 2224 2233 $found = false; 2225 2234 $url_attr = false; 2235 $gradient_attr = false; 2226 2236 2227 2237 if ( strpos( $css_item, ':' ) === false ) { 2228 2238 $found = true; … … 2231 2241 $css_selector = trim( $parts[0] ); 2232 2242 2233 2243 if ( in_array( $css_selector, $allowed_attr, true ) ) { 2234 $found = true; 2235 $url_attr = in_array( $css_selector, $css_url_data_types, true ); 2244 $found = true; 2245 $url_attr = in_array( $css_selector, $css_url_data_types, true ); 2246 $gradient_attr = in_array( $css_selector, $css_gradient_data_types, true ); 2236 2247 } 2237 2248 } 2238 2249 … … 2261 2272 } 2262 2273 } 2263 2274 2275 if ( $found && $gradient_attr ) { 2276 $css_value = trim( $parts[1] ); 2277 if ( preg_match( '/^(repeating-)?(linear|radial|conic)-gradient\(([^()]|rgb[a]?\([^()]*\))*\)$/', $css_value ) ) { 2278 // Remove the whole `gradient` bit that was matched above from the CSS. 2279 $css_test_string = str_replace( $css_value, '', $css_test_string ); 2280 } 2281 } 2282 2264 2283 // Remove any CSS containing containing \ ( & } = or comments, except for url() useage checked above. 2265 2284 if ( $found && ! preg_match( '%[\\\(&=}]|/\*%', $css_test_string ) ) { 2266 2285 if ( $css != '' ) { -
tests/phpunit/tests/kses.php
878 878 'css' => 'columns: 6rem auto;column-count: 4;column-fill: balance;column-gap: 9px;column-rule: thick inset blue;column-span: none;column-width: 120px', 879 879 'expected' => 'columns: 6rem auto;column-count: 4;column-fill: balance;column-gap: 9px;column-rule: thick inset blue;column-span: none;column-width: 120px', 880 880 ), 881 // Gradients introduced in 5.3. 882 array( 883 'css' => 'background: linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)', 884 'expected' => 'background: linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)', 885 ), 886 array( 887 'css' => 'background: linear-gradient(135deg,rgba(6,147,227,1) ) (0%,rgb(155,81,224) 100%)', 888 'expected' => '', 889 ), 890 array( 891 'css' => 'background-image: linear-gradient(red,yellow);', 892 'expected' => 'background-image: linear-gradient(red,yellow)', 893 ), 894 array( 895 'css' => 'color: linear-gradient(red,yellow);', 896 'expected' => '', 897 ), 898 array( 899 'css' => 'background-image: linear-gradient(red,yellow); background: prop( red,yellow); width: 100px;', 900 'expected' => 'background-image: linear-gradient(red,yellow);width: 100px', 901 ), 902 array( 903 'css' => 'background: unknown-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)', 904 'expected' => '', 905 ), 906 array( 907 'css' => 'background: repeating-linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)', 908 'expected' => 'background: repeating-linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)', 909 ), 910 array( 911 'css' => 'width: 100px; height: 100px; background: linear-gradient(135deg,rgba(0,208,132,1) 0%,rgba(6,147,227,1) 100%);', 912 'expected' => 'width: 100px;height: 100px;background: linear-gradient(135deg,rgba(0,208,132,1) 0%,rgba(6,147,227,1) 100%)', 913 ), 914 array( 915 'css' => 'background: radial-gradient(#ff0, red, yellow, green, rgba(6,147,227,1), rgb(155,81,224) 90%);', 916 'expected' => 'background: radial-gradient(#ff0, red, yellow, green, rgba(6,147,227,1), rgb(155,81,224) 90%)', 917 ), 918 array( 919 'css' => 'background: radial-gradient(#ff0, red, yellow, green, rgba(6,147,227,1), rgb(155,81,224) 90%);', 920 'expected' => 'background: radial-gradient(#ff0, red, yellow, green, rgba(6,147,227,1), rgb(155,81,224) 90%)', 921 ), 922 array( 923 'css' => 'background: conic-gradient(at 0% 30%, red 10%, yellow 30%, #1e90ff 50%)', 924 'expected' => 'background: conic-gradient(at 0% 30%, red 10%, yellow 30%, #1e90ff 50%)', 925 ), 926 881 927 ); 882 928 } 883 929