Make WordPress Core

Changeset 52485


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

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

Location:
branches/3.8
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/3.8

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

    r32434 r52485  
    10421042        while( $rows = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20" ) ) {
    10431043            foreach( $rows as $row ) {
    1044                 $value = $row->option_value;
    1045                 if ( !@unserialize( $value ) )
     1044                $value = maybe_unserialize( $row->option_value );
     1045                if ( $value === $row->option_value )
    10461046                    $value = stripslashes( $value );
    10471047                if ( $value !== $row->option_value ) {
  • branches/3.8/src/wp-includes/formatting.php

    r47661 r52485  
    678678 *
    679679 * @since 1.5.0
     680 * @since 5.8.3 Added the `encode_ascii_characters` parameter.
    680681 *
    681682 * @param string $utf8_string
    682683 * @param int $length Max length of the string
     684 * @param bool   $encode_ascii_characters Whether to encode ascii characters such as < " '
    683685 * @return string String with Unicode encoded for URI.
    684686 */
    685 function utf8_uri_encode( $utf8_string, $length = 0 ) {
     687function utf8_uri_encode( $utf8_string, $length = 0, $encode_ascii_characters = false ) {
    686688    $unicode = '';
    687689    $values = array();
     
    695697
    696698        if ( $value < 128 ) {
    697             if ( $length && ( $unicode_length >= $length ) )
     699            $char                = chr( $value );
     700            $encoded_char        = $encode_ascii_characters ? rawurlencode( $char ) : $char;
     701            $encoded_char_length = strlen( $encoded_char );
     702            if ( $length && ( $unicode_length + $encoded_char_length ) > $length ) {
    698703                break;
    699             $unicode .= chr($value);
    700             $unicode_length++;
     704            }
     705            $unicode        .= $encoded_char;
     706            $unicode_length += $encoded_char_length;
    701707        } else {
    702708            if ( count( $values ) == 0 ) $num_octets = ( $value < 224 ) ? 2 : 3;
  • branches/3.8/src/wp-includes/post.php

    r43404 r52485  
    31833183            $slug = substr( $slug, 0, $length );
    31843184        else
    3185             $slug = utf8_uri_encode( $decoded_slug, $length );
     3185            $slug = utf8_uri_encode( $decoded_slug, $length, true );
    31863186    }
    31873187
  • branches/3.8/src/wp-includes/taxonomy.php

    r37141 r52485  
    813813        }
    814814
    815         $query['terms'] = array_unique( (array) $query['terms'] );
     815        if ( 'slug' === $query['field'] || 'name' === $query['field'] ) {
     816            $query['terms'] = array_unique( (array) $query['terms'] );
     817        } else {
     818            $query['terms'] = wp_parse_id_list( $query['terms'] );
     819        }
    816820
    817821        if ( is_taxonomy_hierarchical( $query['taxonomy'] ) && $query['include_children'] ) {
Note: See TracChangeset for help on using the changeset viewer.