Make WordPress Core


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

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

Location:
branches/5.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.3

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

    r47644 r52470  
    11561156 *
    11571157 * @since 1.5.0
    1158  *
    1159  * @param string $utf8_string
    1160  * @param int    $length Max  length of the string
     1158 * @since 5.8.3 Added the `encode_ascii_characters` parameter.
     1159 *
     1160 * @param string $utf8_string             String to encode.
     1161 * @param int    $length                  Max length of the string
     1162 * @param bool   $encode_ascii_characters Whether to encode ascii characters such as < " '
    11611163 * @return string String with Unicode encoded for URI.
    11621164 */
    1163 function utf8_uri_encode( $utf8_string, $length = 0 ) {
     1165function utf8_uri_encode( $utf8_string, $length = 0, $encode_ascii_characters = false ) {
    11641166    $unicode        = '';
    11651167    $values         = array();
     
    11761178
    11771179        if ( $value < 128 ) {
    1178             if ( $length && ( $unicode_length >= $length ) ) {
     1180            $char                = chr( $value );
     1181            $encoded_char        = $encode_ascii_characters ? rawurlencode( $char ) : $char;
     1182            $encoded_char_length = strlen( $encoded_char );
     1183            if ( $length && ( $unicode_length + $encoded_char_length ) > $length ) {
    11791184                break;
    11801185            }
    1181             $unicode .= chr( $value );
    1182             $unicode_length++;
     1186            $unicode        .= $encoded_char;
     1187            $unicode_length += $encoded_char_length;
    11831188        } else {
    11841189            if ( count( $values ) == 0 ) {
Note: See TracChangeset for help on using the changeset viewer.