Make WordPress Core


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

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

Location:
branches/5.2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.2

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

    r47645 r52471  
    11511151 *
    11521152 * @since 1.5.0
    1153  *
    1154  * @param string $utf8_string
    1155  * @param int    $length Max  length of the string
     1153 * @since 5.8.3 Added the `encode_ascii_characters` parameter.
     1154 *
     1155 * @param string $utf8_string             String to encode.
     1156 * @param int    $length                  Max length of the string
     1157 * @param bool   $encode_ascii_characters Whether to encode ascii characters such as < " '
    11561158 * @return string String with Unicode encoded for URI.
    11571159 */
    1158 function utf8_uri_encode( $utf8_string, $length = 0 ) {
     1160function utf8_uri_encode( $utf8_string, $length = 0, $encode_ascii_characters = false ) {
    11591161    $unicode        = '';
    11601162    $values         = array();
     
    11711173
    11721174        if ( $value < 128 ) {
    1173             if ( $length && ( $unicode_length >= $length ) ) {
     1175            $char                = chr( $value );
     1176            $encoded_char        = $encode_ascii_characters ? rawurlencode( $char ) : $char;
     1177            $encoded_char_length = strlen( $encoded_char );
     1178            if ( $length && ( $unicode_length + $encoded_char_length ) > $length ) {
    11741179                break;
    11751180            }
    1176             $unicode .= chr( $value );
    1177             $unicode_length++;
     1181            $unicode        .= $encoded_char;
     1182            $unicode_length += $encoded_char_length;
    11781183        } else {
    11791184            if ( count( $values ) == 0 ) {
Note: See TracChangeset for help on using the changeset viewer.