#36656 [Opn->Csd]: http_build_query generates invalid URIs due to use of square brackets

From: Date: Wed, 08 Mar 2006 22:08:26 +0000
Subject: #36656 [Opn->Csd]: http_build_query generates invalid URIs due to use of square brackets
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-94066@lists.php.net to get a copy of this message
ID: 36656 Updated by: mike@php.net Reported By: php at colin dot guthr dot ie -Status: Open +Status: Closed Bug Type: *URL Functions Operating System: Linux 2.6.12 PHP Version: 5.1.2 New Comment: This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2006-03-08 16:18:59] php at colin dot guthr dot ie Description: ------------ According to RFC3986, which I beleive to be the latest in a long line of RFCs on URI syntaxt, it is illegal to use square brackets in the search string. There is a comment on the PHP manual page for rawurlencode that states that these are now permitted but extensive RFC reading and googling fails to back this up for me. From what I can gather they should be encoded as %5B and %5D. Here is the pseudo fix: str_replace(array('[',']'), array('%5B','%5D'), http_build_query(array('hello' => array('interesting','eh')))) The fix is quite simple and some small changes need to be made to http.c - I've not got a patch unfortunatly, but it should only take a short while to fix and would probably take just as long as a patch review ;) Reproduce code: --------------- echo http_build_query(array('hello' => array('interesting','eh')))."\n"; Expected result: ---------------- hello%5B0%5D=interesting&hello%5B1%5D=eh Actual result: -------------- hello[0]=interesting&hello[1]=eh ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=36656&edit=1

« previous php.bugs (#94066) next »