Make WordPress Core

Ticket #54160: 54160.diff

File 54160.diff, 1.1 KB (added by dd32, 4 months ago)
  • wp-includes/formatting.php

    function sanitize_user( $username, $stri 
    21252125}
    21262126
    21272127/**
    21282128 * Sanitizes a string key.
    21292129 *
    21302130 * Keys are used as internal identifiers. Lowercase alphanumeric characters,
    21312131 * dashes, and underscores are allowed.
    21322132 *
    21332133 * @since 3.0.0
    21342134 *
    21352135 * @param string $key String key
    21362136 * @return string Sanitized key
    21372137 */
    21382138function sanitize_key( $key ) {
    21392139        $raw_key = $key;
    2140         $key     = strtolower( $key );
    2141         $key     = preg_replace( '/[^a-z0-9_\-]/', '', $key );
     2140        if ( ! is_string( $key ) ) {
     2141                $key = '';
     2142        }
     2143
     2144        $key = strtolower( $key );
     2145        $key = preg_replace( '/[^a-z0-9_\-]/', '', $key );
    21422146
    21432147        /**
    21442148         * Filters a sanitized key string.
    21452149         *
    21462150         * @since 3.0.0
    21472151         *
    21482152         * @param string $key     Sanitized key.
    21492153         * @param string $raw_key The key prior to sanitization.
    21502154         */
    21512155        return apply_filters( 'sanitize_key', $key, $raw_key );
    21522156}
    21532157
    21542158/**
    21552159 * Sanitizes a string into a slug, which can be used in URLs or HTML attributes.
    21562160 *