Changeset 31587
- Timestamp:
- 02/28/2015 02:20:52 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/pluggable.php
r31561 r31587 1202 1202 **/ 1203 1203 function wp_sanitize_redirect($location) { 1204 $regex = '/ 1205 ( 1206 (?: [\xC2-\xDF][\x80-\xBF] # double-byte sequences 110xxxxx 10xxxxxx 1207 | \xE0[\xA0-\xBF][\x80-\xBF] # triple-byte sequences 1110xxxx 10xxxxxx * 2 1208 | [\xE1-\xEC][\x80-\xBF]{2} 1209 | \xED[\x80-\x9F][\x80-\xBF] 1210 | [\xEE-\xEF][\x80-\xBF]{2} 1211 | \xF0[\x90-\xBF][\x80-\xBF]{2} # four-byte sequences 11110xxx 10xxxxxx * 3 1212 | [\xF1-\xF3][\x80-\xBF]{3} 1213 | \xF4[\x80-\x8F][\x80-\xBF]{2} 1214 ){1,50} # ...one or more times 1215 )/x'; 1216 $location = preg_replace_callback( $regex, '_wp_sanitize_utf8_in_redirect', $location ); 1204 1217 $location = preg_replace('|[^a-z0-9-~+_.?#=&;,/:%!*\[\]()]|i', '', $location); 1205 1218 $location = wp_kses_no_null($location); … … 1209 1222 $location = _deep_replace($strip, $location); 1210 1223 return $location; 1224 } 1225 1226 /** 1227 * URL encode UTF-8 characters in a URL. 1228 * 1229 * @ignore 1230 * @since 4.2.0 1231 * @access private 1232 * 1233 * @see wp_sanitize_redirect() 1234 */ 1235 function _wp_sanitize_utf8_in_redirect( $matches ) { 1236 return urlencode( $matches[0] ); 1211 1237 } 1212 1238 endif; -
trunk/tests/phpunit/tests/formatting/redirect.php
r30684 r31587 12 12 $this->assertEquals('http://example.com/watchthecarriagereturngo', wp_sanitize_redirect('http://example.com/watchthecarriagereturn%0dgo')); 13 13 $this->assertEquals('http://example.com/watchtheallowedcharacters-~+_.?#=&;,/:%!*stay', wp_sanitize_redirect('http://example.com/watchtheallowedcharacters-~+_.?#=&;,/:%!*stay')); 14 $this->assertEquals('http://example.com/watchtheutf8convert%F0%9D%8C%86', wp_sanitize_redirect("http://example.com/watchtheutf8convert\xf0\x9d\x8c\x86")); 14 15 //Nesting checks 15 16 $this->assertEquals('http://example.com/watchthecarriagereturngo', wp_sanitize_redirect('http://example.com/watchthecarriagereturn%0%0ddgo'));
Note: See TracChangeset
for help on using the changeset viewer.