From 6ebc722218989a4d1e4d114e3e163bb92f07bd9f Mon Sep 17 00:00:00 2001 From: whyisjake Date: Wed, 29 Apr 2020 16:25:25 +0000 Subject: [PATCH] User: Invalidate `user_activation_key` on password update. Query: Ensure that only a single post can be returned on date/time based queries. Cache API: Ensure proper escaping around the stats method in the cache API. Formatting: Expand `sanitize_file_name` to have better support for utf8 characters. Brings the changes in [47634], [47635], [47637], and [47638] to the 4.6 branch. Props: batmoo, ehti, nickdaugherty, peterwilsoncc, sergeybiryukov, sstoqnov, westi, whyisjake, whyisjake, xknown. Built from https://develop.svn.wordpress.org/branches/4.6@47651 git-svn-id: http://core.svn.wordpress.org/branches/4.6@47426 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/formatting.php | 19 ++++++++++++++++++- wp-includes/query.php | 4 ---- wp-includes/user.php | 2 +- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 33d606e483..785fd83c00 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -1744,6 +1744,24 @@ function remove_accents( $string ) { function sanitize_file_name( $filename ) { $filename_raw = $filename; $special_chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}", "%", "+", chr(0)); + + // Check for support for utf8 in the installed PCRE library once and store the result in a static. + static $utf8_pcre = null; + if ( ! isset( $utf8_pcre ) ) { + // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged + $utf8_pcre = @preg_match( '/^./u', 'a' ); + } + + if ( ! seems_utf8( $filename ) ) { + $_ext = pathinfo( $filename, PATHINFO_EXTENSION ); + $_name = pathinfo( $filename, PATHINFO_FILENAME ); + $filename = sanitize_title_with_dashes( $_name ) . '.' . $_ext; + } + + if ( $utf8_pcre ) { + $filename = preg_replace( "#\x{00a0}#siu", ' ', $filename ); + } + /** * Filters the list of characters to remove from a filename. * @@ -1753,7 +1771,6 @@ function sanitize_file_name( $filename ) { * @param string $filename_raw Filename as it was passed into sanitize_file_name(). */ $special_chars = apply_filters( 'sanitize_file_name_chars', $special_chars, $filename_raw ); - $filename = preg_replace( "#\x{00a0}#siu", ' ', $filename ); $filename = str_replace( $special_chars, '', $filename ); $filename = str_replace( array( '%20', '+' ), '-', $filename ); $filename = preg_replace( '/[\r\n\t -]+/', '-', $filename ); diff --git a/wp-includes/query.php b/wp-includes/query.php index 24531ce35e..a4e3897710 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -1632,10 +1632,6 @@ class WP_Query { $this->is_single = true; } elseif ( $qv['p'] ) { $this->is_single = true; - } elseif ( ('' !== $qv['hour']) && ('' !== $qv['minute']) &&('' !== $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day']) ) { - // If year, month, day, hour, minute, and second are set, a single - // post is being queried. - $this->is_single = true; } elseif ( '' != $qv['pagename'] || !empty($qv['page_id']) ) { $this->is_page = true; $this->is_single = false; diff --git a/wp-includes/user.php b/wp-includes/user.php index 6d473ef4c8..84366e5596 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -1612,7 +1612,7 @@ function wp_insert_user( $userdata ) { $data = wp_unslash( $compacted ); if ( $update ) { - if ( $user_email !== $old_user_data->user_email ) { + if ( $user_email !== $old_user_data->user_email || $user_pass !== $old_user_data->user_pass ) { $data['user_activation_key'] = ''; } $wpdb->update( $wpdb->users, $data, compact( 'ID' ) );