Make WordPress Core

Changeset 52483


Ignore:
Timestamp:
01/06/2022 06:25:11 PM (3 years ago)
Author:
desrosj
Message:

Grouped backports to the 4.0 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 4.0 branch.
Props vortfu, dd32, ehtis, zieladam, whyisjake, xknown, peterwilsoncc, desrosj, iandunn.

Location:
branches/4.0
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/4.0

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

    r32432 r52483  
    10761076        while( $rows = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20" ) ) {
    10771077            foreach( $rows as $row ) {
    1078                 $value = $row->option_value;
    1079                 if ( !@unserialize( $value ) )
     1078                $value = maybe_unserialize( $row->option_value );
     1079                if ( $value === $row->option_value )
    10801080                    $value = stripslashes( $value );
    10811081                if ( $value !== $row->option_value ) {
  • branches/4.0/src/wp-includes/formatting.php

    r47659 r52483  
    859859 *
    860860 * @since 1.5.0
     861 * @since 5.8.3 Added the `encode_ascii_characters` parameter.
    861862 *
    862863 * @param string $utf8_string
    863864 * @param int $length Max length of the string
     865 * @param bool   $encode_ascii_characters Whether to encode ascii characters such as < " '
    864866 * @return string String with Unicode encoded for URI.
    865867 */
    866 function utf8_uri_encode( $utf8_string, $length = 0 ) {
     868function utf8_uri_encode( $utf8_string, $length = 0, $encode_ascii_characters = false ) {
    867869    $unicode = '';
    868870    $values = array();
     
    879881
    880882        if ( $value < 128 ) {
    881             if ( $length && ( $unicode_length >= $length ) )
     883            $char                = chr( $value );
     884            $encoded_char        = $encode_ascii_characters ? rawurlencode( $char ) : $char;
     885            $encoded_char_length = strlen( $encoded_char );
     886            if ( $length && ( $unicode_length + $encoded_char_length ) > $length ) {
    882887                break;
    883             $unicode .= chr($value);
    884             $unicode_length++;
     888            }
     889            $unicode        .= $encoded_char;
     890            $unicode_length += $encoded_char_length;
    885891        } else {
    886892            if ( count( $values ) == 0 ) $num_octets = ( $value < 224 ) ? 2 : 3;
  • branches/4.0/src/wp-includes/post.php

    r43402 r52483  
    37903790            $slug = substr( $slug, 0, $length );
    37913791        else
    3792             $slug = utf8_uri_encode( $decoded_slug, $length );
     3792            $slug = utf8_uri_encode( $decoded_slug, $length, true );
    37933793    }
    37943794
  • branches/4.0/src/wp-includes/taxonomy.php

    r37139 r52483  
    834834        }
    835835
    836         $query['terms'] = array_unique( (array) $query['terms'] );
     836        if ( 'slug' === $query['field'] || 'name' === $query['field'] ) {
     837            $query['terms'] = array_unique( (array) $query['terms'] );
     838        } else {
     839            $query['terms'] = wp_parse_id_list( $query['terms'] );
     840        }
    837841
    838842        if ( is_taxonomy_hierarchical( $query['taxonomy'] ) && $query['include_children'] ) {
Note: See TracChangeset for help on using the changeset viewer.