#18814 closed enhancement (wontfix)
wp_redirect wont allow arrays to be sent in query string
Reported by: | jacksplay | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.2.1 |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
The pluggable function wp-redirect will not allow arrays to be sent in a query string.
ie: http://www.example.com/?array[]=first&array[]=second&array[]=last
The brackets are stripped out when the URL is sanitized and it becomes:
http://www.example.com/?array=first&array=second&array=last
This removes the ability to pass the array.
Change History (4)
#2
@
13 years ago
Just to update for other users searching about this issue.
You will need to encode this when sending an array to another script or in my case I needed to send a link in an email with the array.
$query = "array[]=first&array[]=second&array[]=last"; $query =str_replace(array('[',']'), array('%5B','%5D'), $query); wp_redirect("http://www.example.com/?$query",302);
url_encode() will not encode the brackets because the square bracket is allowed in a URI.
Note: See
TracTickets for help on using
tickets.
Brackets are reserved characters for enclosing IP literals. They should be encoded when used elsewhere. Encoding them on our own is something we don't currently do, and changing it may possibly have backwards compatibility issues. See also #10281.
One thought might be to automatically encode
[]
, together, to allow general array passing, and only if it appears in the query string.