Make WordPress Core


Ignore:
Timestamp:
06/02/2020 11:44:40 PM (5 years ago)
Author:
adamsilverstein
Message:

Formatting: add a new 'safe_style_disallowed_chars' filter.

Enable developers to change the regex used in safecss_filter_attr to limit characters in the parsed CSS.

Props paulschreiber, swissspidy, rmccue, bartekcholewa, miinasikk.
Fixes #37134.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/kses.php

    r47837 r47891  
    23022302        }
    23032303
    2304         // Remove any CSS containing containing \ ( & } = or comments, except for url() useage checked above.
    2305         if ( $found && ! preg_match( '%[\\\(&=}]|/\*%', $css_test_string ) ) {
    2306             if ( '' !== $css ) {
    2307                 $css .= ';';
     2304        if ( $found ) {
     2305            /**
     2306             * Filters the regex limiting the list of characters not allowed in CSS rules.
     2307             *
     2308             * Default behaviour is to remove any css containing \ ( & } = or comments, except for url() usage.
     2309             *
     2310             * @since 5.5.0
     2311             *
     2312             * @param string $regex           Regex pattern of disallowed characters in CSS rules. Default is '%[\\\(&=}]|/\*%'.
     2313             * @param string $css_test_string CSS value to test.
     2314             */
     2315            $disallowed_chars = apply_filters( 'safe_style_disallowed_chars', '%[\\\(&=}]|/\*%', $css_test_string );
     2316            if ( ! preg_match( $disallowed_chars, $css_test_string ) ) {
     2317                if ( '' !== $css ) {
     2318                    $css .= ';';
     2319                }
     2320                $css .= $css_item;
    23082321            }
    2309 
    2310             $css .= $css_item;
    23112322        }
    23122323    }
Note: See TracChangeset for help on using the changeset viewer.