Changeset 52472 for branches/5.1/src/wp-includes/formatting.php
- Timestamp:
- 01/06/2022 06:12:33 PM (3 years ago)
- Location:
- branches/5.1
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.1
- Property svn:mergeinfo changed
/trunk merged: 52454-52457
- Property svn:mergeinfo changed
-
branches/5.1/src/wp-includes/formatting.php
r47646 r52472 1151 1151 * 1152 1152 * @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 < " ' 1156 1158 * @return string String with Unicode encoded for URI. 1157 1159 */ 1158 function utf8_uri_encode( $utf8_string, $length = 0 ) {1160 function utf8_uri_encode( $utf8_string, $length = 0, $encode_ascii_characters = false ) { 1159 1161 $unicode = ''; 1160 1162 $values = array(); … … 1171 1173 1172 1174 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 ) { 1174 1179 break; 1175 1180 } 1176 $unicode .= chr( $value );1177 $unicode_length ++;1181 $unicode .= $encoded_char; 1182 $unicode_length += $encoded_char_length; 1178 1183 } else { 1179 1184 if ( count( $values ) == 0 ) {
Note: See TracChangeset
for help on using the changeset viewer.