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 3.9 branch.

Props: batmoo, ehti, nickdaugherty, peterwilsoncc, sergeybiryukov, sstoqnov, westi, whyisjake, whyisjake, xknown.

Built from https://develop.svn.wordpress.org/branches/3.9@47660


git-svn-id: http://core.svn.wordpress.org/branches/3.9@47437 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
whyisjake 2020-04-29 16:56:12 +00:00
parent a6e4d88a7a
commit 348c871b83
4 changed files with 20 additions and 7 deletions

View File

@ -587,7 +587,7 @@ class WP_Object_Cache {
echo "</p>"; echo "</p>";
echo '<ul>'; echo '<ul>';
foreach ($this->cache as $group => $cache) { foreach ($this->cache as $group => $cache) {
echo "<li><strong>Group:</strong> $group - ( " . number_format( strlen( serialize( $cache ) ) / 1024, 2 ) . 'k )</li>'; echo '<li><strong>Group:</strong> ' . esc_html( $group ) . ' - ( ' . number_format( strlen( serialize( $cache ) ) / KB_IN_BYTES, 2 ) . 'k )</li>';
} }
echo '</ul>'; echo '</ul>';
} }

View File

@ -1035,6 +1035,24 @@ function remove_accents($string) {
function sanitize_file_name( $filename ) { function sanitize_file_name( $filename ) {
$filename_raw = $filename; $filename_raw = $filename;
$special_chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}", chr(0)); $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 );
}
/** /**
* Filter the list of characters to remove from a filename. * Filter the list of characters to remove from a filename.
* *
@ -1044,7 +1062,6 @@ function sanitize_file_name( $filename ) {
* @param string $filename_raw Filename as it was passed into sanitize_file_name(). * @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 ); $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($special_chars, '', $filename);
$filename = preg_replace('/[\s-]+/', '-', $filename); $filename = preg_replace('/[\s-]+/', '-', $filename);
$filename = trim($filename, '.-_'); $filename = trim($filename, '.-_');

View File

@ -1501,10 +1501,6 @@ class WP_Query {
$this->is_single = true; $this->is_single = true;
} elseif ( $qv['p'] ) { } elseif ( $qv['p'] ) {
$this->is_single = true; $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']) ) { } elseif ( '' != $qv['pagename'] || !empty($qv['page_id']) ) {
$this->is_page = true; $this->is_page = true;
$this->is_single = false; $this->is_single = false;

View File

@ -1716,7 +1716,7 @@ function wp_insert_user( $userdata ) {
$data = wp_unslash( $data ); $data = wp_unslash( $data );
if ( $update ) { 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'] = ''; $data['user_activation_key'] = '';
} }
$wpdb->update( $wpdb->users, $data, compact( 'ID' ) ); $wpdb->update( $wpdb->users, $data, compact( 'ID' ) );