Make WordPress Core

Changeset 52486


Ignore:
Timestamp:
01/06/2022 06:27:19 PM (2 years ago)
Author:
desrosj
Message:

Grouped backports to the 3.7 branch.

  • Query: Improve sanitization within WP_Tax_Query.
  • Upgrade/Install: Avoid using unserialize() unnecessarily.
  • Formatting: Correctly encode ASCII characters in post slugs.

Merges [52454,52456-52457] to the 3.7 branch.
Props vortfu, dd32, ehtis, zieladam, whyisjake, xknown, peterwilsoncc, desrosj, iandunn.

Location:
branches/3.7
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/3.7

  • branches/3.7/src

  • branches/3.7/src/wp-admin/includes/upgrade.php

    r47343 r52486  
    10391039        while( $rows = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20" ) ) {
    10401040            foreach( $rows as $row ) {
    1041                 $value = $row->option_value;
    1042                 if ( !@unserialize( $value ) )
     1041                $value = maybe_unserialize( $row->option_value );
     1042                if ( $value === $row->option_value )
    10431043                    $value = stripslashes( $value );
    10441044                if ( $value !== $row->option_value ) {
  • branches/3.7/src/wp-includes/formatting.php

    r47662 r52486  
    664664 *
    665665 * @since 1.5.0
     666 * @since 5.8.3 Added the `encode_ascii_characters` parameter.
    666667 *
    667668 * @param string $utf8_string
    668669 * @param int $length Max length of the string
     670 * @param bool   $encode_ascii_characters Whether to encode ascii characters such as < " '
    669671 * @return string String with Unicode encoded for URI.
    670672 */
    671 function utf8_uri_encode( $utf8_string, $length = 0 ) {
     673function utf8_uri_encode( $utf8_string, $length = 0, $encode_ascii_characters = false ) {
    672674    $unicode = '';
    673675    $values = array();
     
    681683
    682684        if ( $value < 128 ) {
    683             if ( $length && ( $unicode_length >= $length ) )
     685            $char                = chr( $value );
     686            $encoded_char        = $encode_ascii_characters ? rawurlencode( $char ) : $char;
     687            $encoded_char_length = strlen( $encoded_char );
     688            if ( $length && ( $unicode_length + $encoded_char_length ) > $length ) {
    684689                break;
    685             $unicode .= chr($value);
    686             $unicode_length++;
     690            }
     691            $unicode        .= $encoded_char;
     692            $unicode_length += $encoded_char_length;
    687693        } else {
    688694            if ( count( $values ) == 0 ) $num_octets = ( $value < 224 ) ? 2 : 3;
  • branches/3.7/src/wp-includes/post.php

    r43405 r52486  
    31763176            $slug = substr( $slug, 0, $length );
    31773177        else
    3178             $slug = utf8_uri_encode( $decoded_slug, $length );
     3178            $slug = utf8_uri_encode( $decoded_slug, $length, true );
    31793179    }
    31803180
  • branches/3.7/src/wp-includes/taxonomy.php

    r37142 r52486  
    811811        }
    812812
    813         $query['terms'] = array_unique( (array) $query['terms'] );
     813        if ( 'slug' === $query['field'] || 'name' === $query['field'] ) {
     814            $query['terms'] = array_unique( (array) $query['terms'] );
     815        } else {
     816            $query['terms'] = wp_parse_id_list( $query['terms'] );
     817        }
    814818
    815819        if ( is_taxonomy_hierarchical( $query['taxonomy'] ) && $query['include_children'] ) {
Note: See TracChangeset for help on using the changeset viewer.