From: php at colin dot guthr dot ie Operating system: Linux 2.6.12 PHP version: 5.1.2 PHP Bug Type: *URL Functions Bug description: http_build_query generates invalid URIs due to use of square brackets
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 bug report at http://bugs.php.net/?id=36656&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=36656&r=trysnapshot44 Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=36656&r=trysnapshot51 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=36656&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=36656&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=36656&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=36656&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=36656&r=needscript Try newer version: http://bugs.php.net/fix.php?id=36656&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=36656&r=support Expected behavior: http://bugs.php.net/fix.php?id=36656&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=36656&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=36656&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=36656&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36656&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=36656&r=dst IIS Stability: http://bugs.php.net/fix.php?id=36656&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=36656&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=36656&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=36656&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=36656&r=mysqlcfg