#31486 closed defect (bug) (fixed)
wp_redirect sends incorrect url when it contains non escaped unicode characters
Reported by: | louyx | Owned by: | pento |
---|---|---|---|
Milestone: | 4.2 | Priority: | normal |
Severity: | normal | Version: | 2.3 |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
TL;DR:
When using wp_redirect to a url that contains non-ascii letters, those letters are stripped out from the HTTP Location header.
I have created a small fix for this issue by escaping every non-ascii character:
$redirect_url = preg_replace_callback('/([^\x00-\x7F])/i', function($matches) { return urlencode($matches[1]); }, $redirect_url);
More Details:
Some plugins redirect to some urls containing unicode characters without escaping them first. Escape functions esc_url and esc_url_raw do not solve this either. I think solving this at core level is the best thing to do, especially that it doesn't affect the current behavior of the function.
Here's an example (in Arabic, which is RTL):
wp_redirect( 'http://example.com/tag/تجربة-1/' ); //redirects to http://example.com/tag/-1/
Change History (3)
Note: See
TracTickets for help on using
tickets.
In 31587: