WordPress.org

Make WordPress Core

Ticket #26094: 26094.patch

File 26094.patch, 1.1 KB (added by p_enrique, 5 years ago)

Add /u pattern modifier to preg_replace

  • src/wp-includes/formatting.php

     
    844844        $special_chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}", chr(0));
    845845        $special_chars = apply_filters('sanitize_file_name_chars', $special_chars, $filename_raw);
    846846        $filename = str_replace($special_chars, '', $filename);
    847         $filename = preg_replace('/[\s-]+/', '-', $filename);
     847        $filename = preg_replace('/[\p{Z}\s-]+/u', '-', $filename); // Match all UTF-8 whitespace
    848848        $filename = trim($filename, '.-_');
    849849
    850850        // Split the filename into a base and extension[s]
     
    864864        foreach ( (array) $parts as $part) {
    865865                $filename .= '.' . $part;
    866866
    867                 if ( preg_match("/^[a-zA-Z]{2,5}\d?$/", $part) ) {
     867                if ( preg_match("/^[a-zA-Z]{2,5}\d?$/u", $part) ) {
    868868                        $allowed = false;
    869869                        foreach ( $mimes as $ext_preg => $mime_match ) {
    870870                                $ext_preg = '!^(' . $ext_preg . ')$!i';