Make WordPress Core

Changeset 52473


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

Grouped backports to the 5.0 branch.

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

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

Location:
branches/5.0
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0

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

    r43954 r52473  
    one thousand three hundred and twenty-six one thousand three hundred and twenty-six         while( $rows = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20" ) ) {
    one thousand three hundred and twenty-seven one thousand three hundred and twenty-seven             foreach ( $rows as $row ) {
    one thousand three hundred and twenty-eight                   $value = $row->option_value ;
    one thousand three hundred and twenty-nine                   if ( !@ unserialize( $value ) )
      one thousand three hundred and twenty-eight                 $value = maybe_unserialize( $row->option_value ) ;
      one thousand three hundred and twenty-nine                 if ( $value === $row->option_value )
    one thousand three hundred and thirty one thousand three hundred and thirty                     $value = stripslashes( $value );
    one thousand three hundred and thirty-one one thousand three hundred and thirty-one                 if ( $value !== $row->option_value ) {
  • branches/5.0/src/wp-includes/class-wp-meta-query.php

    r41688 r52473  
    six hundred and ninety-six six hundred and ninety-six             $sibling_compare = strtoupper( $sibling['compare'] );
    six hundred and ninety-seven six hundred and ninety-seven             if ( in_array( $clause_compare, $compatible_compares ) && in_array( $sibling_compare, $compatible_compares ) ) {
    six hundred and ninety-eight                   $alias = $sibling['alias'] ;
      six hundred and ninety-eight                 $alias = preg_replace( '/\W/', '_', $sibling['alias'] ) ;
    six hundred and ninety-nine six hundred and ninety-nine                 break;
    seven hundred seven hundred             }
  • branches/5.0/src/wp-includes/class-wp-tax-query.php

    r41688 r52473  
    five hundred and twenty-eight five hundred and twenty-eight             // The sibling must both have compatible operator to share its alias.
    five hundred and twenty-nine five hundred and twenty-nine             if ( in_array( strtoupper( $sibling['operator'] ), $compatible_operators ) ) {
    five hundred and thirty                   $alias = $sibling['alias'] ;
      five hundred and thirty                 $alias = preg_replace( '/\W/', '_', $sibling['alias'] ) ;
    five hundred and thirty-one five hundred and thirty-one                 break;
    five hundred and thirty-two five hundred and thirty-two             }
     
    five hundred and fifty-seven five hundred and fifty-seven         }
    five hundred and fifty-eight five hundred and fifty-eight
    five hundred and fifty-nine           $query['terms'] = array_unique( (array) $query['terms'] );
      five hundred and fifty-nine         if ( 'slug' === $query['field'] || 'name' === $query['field'] ) {
      five hundred and sixty             $query['terms'] = array_unique( (array) $query['terms'] );
      five hundred and sixty-one         } else {
      five hundred and sixty-two             $query['terms'] = wp_parse_id_list( $query['terms'] );
      five hundred and sixty-three         }
    five hundred and sixty five hundred and sixty-four
    five hundred and sixty-one five hundred and sixty-five         if ( is_taxonomy_hierarchical( $query['taxonomy'] ) && $query['include_children'] ) {
  • branches/5.0/src/wp-includes/formatting.php

    r49396 r52473  
    one thousand and eighty-five one thousand and eighty-five  *
    one thousand and eighty-six one thousand and eighty-six  * @since 1.5.0
    one thousand and eighty-seven    *
    one thousand and eighty-eight    * @param string $utf8_string
    one thousand and eighty-nine    * @param int    $length Max  length of the string
      one thousand and eighty-seven  * @since 5.8.3 Added the `encode_ascii_characters` parameter.
      one thousand and eighty-eight  *
      one thousand and eighty-nine  * @param string $utf8_string             String to encode.
      one thousand and ninety  * @param int    $length                  Max length of the string
      one thousand and ninety-one  * @param bool   $encode_ascii_characters Whether to encode ascii characters such as < " '
    one thousand and ninety one thousand and ninety-two  * @return string String with Unicode encoded for URI.
    one thousand and ninety-one one thousand and ninety-three  */
    one thousand and ninety-two   function utf8_uri_encode( $utf8_string, $length = 0 ) {
      one thousand and ninety-four function utf8_uri_encode( $utf8_string, $length = 0 , $encode_ascii_characters = false ) {
    one thousand and ninety-three one thousand and ninety-five     $unicode        = '';
    one thousand and ninety-four one thousand and ninety-six     $values         = array();
     
    one thousand one hundred and five one thousand one hundred and seven
    one thousand one hundred and six one thousand one hundred and eight         if ( $value < 128 ) {
    one thousand one hundred and seven               if ( $length && ( $unicode_length >= $length ) ) {
      one thousand one hundred and nine             $char                = chr( $value );
      one thousand one hundred and ten             $encoded_char        = $encode_ascii_characters ? rawurlencode( $char ) : $char;
      one thousand one hundred and eleven             $encoded_char_length = strlen( $encoded_char );
      one thousand one hundred and twelve             if ( $length && ( $unicode_length + $encoded_char_length ) > $length ) {
    one thousand one hundred and eight one thousand one hundred and thirteen                 break;
    one thousand one hundred and nine one thousand one hundred and fourteen             }
    one thousand one hundred and ten               $unicode .= chr( $value ) ;
    one thousand one hundred and eleven               $unicode_length ++ ;
      one thousand one hundred and fifteen             $unicode        .= $ encoded_char ;
      one thousand one hundred and sixteen             $unicode_length  += $encoded_char_length ;
    one thousand one hundred and twelve one thousand one hundred and seventeen         } else {
    one thousand one hundred and thirteen one thousand one hundred and eighteen             if ( count( $values ) == 0 ) {
  • branches/5.0/src/wp-includes/post.php

    r47647 r52473  
    four thousand and sixty four thousand and sixty             $slug = substr( $slug, 0, $length );
    four thousand and sixty-one four thousand and sixty-one         else
    four thousand and sixty-two               $slug = utf8_uri_encode( $decoded_slug, $length );
      four thousand and sixty-two             $slug = utf8_uri_encode( $decoded_slug, $length , true );
    four thousand and sixty-three four thousand and sixty-three     }
    four thousand and sixty-four four thousand and sixty-four
Note: See TracChangeset for help on using the changeset viewer.