Make WordPress Core


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

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

Location:
branches/4.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9

  • branches/4.9/src/wp-includes/formatting.php

    r49397 r52474  
    10851085 *
    10861086 * @since 1.5.0
    1087  *
    1088  * @param string $utf8_string
    1089  * @param int    $length Max  length of the string
     1087 * @since 5.8.3 Added the `encode_ascii_characters` parameter.
     1088 *
     1089 * @param string $utf8_string             String to encode.
     1090 * @param int    $length                  Max length of the string
     1091 * @param bool   $encode_ascii_characters Whether to encode ascii characters such as < " '
    10901092 * @return string String with Unicode encoded for URI.
    10911093 */
    1092 function utf8_uri_encode( $utf8_string, $length = 0 ) {
     1094function utf8_uri_encode( $utf8_string, $length = 0, $encode_ascii_characters = false ) {
    10931095    $unicode        = '';
    10941096    $values         = array();
     
    11051107
    11061108        if ( $value < 128 ) {
    1107             if ( $length && ( $unicode_length >= $length ) ) {
     1109            $char                = chr( $value );
     1110            $encoded_char        = $encode_ascii_characters ? rawurlencode( $char ) : $char;
     1111            $encoded_char_length = strlen( $encoded_char );
     1112            if ( $length && ( $unicode_length + $encoded_char_length ) > $length ) {
    11081113                break;
    11091114            }
    1110             $unicode .= chr( $value );
    1111             $unicode_length++;
     1115            $unicode        .= $encoded_char;
     1116            $unicode_length += $encoded_char_length;
    11121117        } else {
    11131118            if ( count( $values ) == 0 ) {
Note: See TracChangeset for help on using the changeset viewer.