Make WordPress Core

Opened 10 years ago

Closed 7 years ago

Last modified 7 years ago

#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:


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:


This removes the ability to pass the array.

Change History (4)

#1 @nacin
10 years ago

  • Type changed from defect (bug) to enhancement

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.

#2 @jacksplay
10 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);

url_encode() will not encode the brackets because the square bracket is allowed in a URI.

Last edited 10 years ago by jacksplay (previous) (diff)

#3 @chriscct7
7 years ago

  • Resolution set to wontfix
  • Status changed from new to closed

Per Nacin's comment

#4 @DrewAPicture
7 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.