[wp-trac] [WordPress Trac] #31486: wp_redirect sends incorrect url when it contains non escaped unicode characters
WordPress Trac
noreply at wordpress.org
Sat Feb 28 00:59:52 UTC 2015
#31486: wp_redirect sends incorrect url when it contains non escaped unicode
characters
--------------------------+-----------------------------
Reporter: louyx | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: trunk
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
'''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/
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/31486>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list