[wp-trac] [WordPress Trac] #26037: wp_sanitize_redirect removing valid URIs characters

WordPress Trac noreply at wordpress.org
Fri Nov 15 00:37:19 UTC 2013


#26037: wp_sanitize_redirect removing valid URIs characters
--------------------------+--------------------------------------
 Reporter:  omarabid      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Validation    |    Version:
 Severity:  minor         |   Keywords:  dev-feedback 2nd-opinion
--------------------------+--------------------------------------
 I'm using the wp_redirect function on one of my plugins. One of my users
 found out that in the redirect, the brackets are removed from the URL.

 I dug a little bit and found the culprit to be the function
 "wp_sanitize_redirect" which removes the brackets.

 Here is the regex expression that detects and removes unwanted characters

 {{{
 $location = preg_replace('|[^a-z0-9-~+_.?#=&;,/:%!]|i', '', $location);
 }}}

 Here are the accepted characters in a URI*

 {{{
 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:/?#[]@!$&'()*+,;=
 }}}

 * http://stackoverflow.com/questions/1547899/which-characters-make-a-url-
 invalid/1547940#1547940

 So is there are a reason to remove this characters or is this a bug?

--
Ticket URL: <http://core.trac.wordpress.org/ticket/26037>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list