Make WordPress Core


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

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

Location:
branches/4.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.3

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

    r49403 r52480  
    999999 *
    10001000 * @since 1.5.0
    1001  *
    1002  * @param string $utf8_string
    1003  * @param int    $length Max  length of the string
     1001 * @since 5.8.3 Added the `encode_ascii_characters` parameter.
     1002 *
     1003 * @param string $utf8_string             String to encode.
     1004 * @param int    $length                  Max length of the string
     1005 * @param bool   $encode_ascii_characters Whether to encode ascii characters such as < " '
    10041006 * @return string String with Unicode encoded for URI.
    10051007 */
    1006 function utf8_uri_encode( $utf8_string, $length = 0 ) {
     1008function utf8_uri_encode( $utf8_string, $length = 0, $encode_ascii_characters = false ) {
    10071009    $unicode        = '';
    10081010    $values         = array();
     
    10191021
    10201022        if ( $value < 128 ) {
    1021             if ( $length && ( $unicode_length >= $length ) ) {
     1023            $char                = chr( $value );
     1024            $encoded_char        = $encode_ascii_characters ? rawurlencode( $char ) : $char;
     1025            $encoded_char_length = strlen( $encoded_char );
     1026            if ( $length && ( $unicode_length + $encoded_char_length ) > $length ) {
    10221027                break;
    10231028            }
    1024             $unicode .= chr( $value );
    1025             $unicode_length++;
     1029            $unicode        .= $encoded_char;
     1030            $unicode_length += $encoded_char_length;
    10261031        } else {
    10271032            if ( count( $values ) == 0 ) {
Note: See TracChangeset for help on using the changeset viewer.