Make WordPress Core

Opened 15 years ago

Closed 12 years ago

Last modified 12 years ago

#18814 closed enhancement (wontfix)

wp_redirect wont allow arrays to be sent in query string

Reported by: jacksplay Owned by:
Priority: normal Milestone:
Component: General Version: 3.2.1
Severity: normal Keywords:
Cc: Focuses:

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)

#1 @nacin
15 years ago

  • Type defect (bug)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
15 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.

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

#3 @chriscct7
12 years ago

  • Resolutionwontfix
  • Status newclosed

Per Nacin's comment

#4 @DrewAPicture
12 years ago

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