Changeset 52481 for branches/4.2/src/wp-includes/formatting.php
- Timestamp:
- 01/06/2022 06:19:36 PM (3 years ago)
- Location:
- branches/4.2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.2
- Property svn:mergeinfo changed
/trunk merged: 52454-52457
- Property svn:mergeinfo changed
-
branches/4.2/src/wp-includes/formatting.php
r47657 r52481 909 909 * 910 910 * @since 1.5.0 911 * @since 5.8.3 Added the `encode_ascii_characters` parameter. 911 912 * 912 913 * @param string $utf8_string 913 914 * @param int $length Max length of the string 915 * @param bool $encode_ascii_characters Whether to encode ascii characters such as < " ' 914 916 * @return string String with Unicode encoded for URI. 915 917 */ 916 function utf8_uri_encode( $utf8_string, $length = 0 ) {918 function utf8_uri_encode( $utf8_string, $length = 0, $encode_ascii_characters = false ) { 917 919 $unicode = ''; 918 920 $values = array(); … … 929 931 930 932 if ( $value < 128 ) { 931 if ( $length && ( $unicode_length >= $length ) ) 933 $char = chr( $value ); 934 $encoded_char = $encode_ascii_characters ? rawurlencode( $char ) : $char; 935 $encoded_char_length = strlen( $encoded_char ); 936 if ( $length && ( $unicode_length + $encoded_char_length ) > $length ) { 932 937 break; 933 $unicode .= chr($value); 934 $unicode_length++; 938 } 939 $unicode .= $encoded_char; 940 $unicode_length += $encoded_char_length; 935 941 } else { 936 942 if ( count( $values ) == 0 ) {
Note: See TracChangeset
for help on using the changeset viewer.