Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.1.2

Bug #21153 When OPTION_ENCODE_KEYS is set to true, some brackets ([ and ]) arent' encoded
Submitted: 2016-12-10 00:52 UTC
From: jayklehr Assigned:
Status: Open Package: Net_URL2 (version 2.1.2)
PHP Version: 5.6.27 OS: osx
Roadmaps: (Not assigned)    
Subscription  


 [2016-12-10 00:52 UTC] jayklehr (Jay Klehr)
Description: ------------ I noticed when running some tests against Net_URL2 that stray/non-matching brackets (like those used in the query string test of the library) are encoded with %5B and %5D, but if the brackets are the result of building from a PHP array, they're not encoded. This appears to be because of this line in URL2.php: > $name = $key . '[' . $name . ']'; The `rawurlencode` for the $key parameter happens earlier in this method, so the brackets remain untouched. Test script: --------------- <?php $url = new Net_URL2(''); $url->setQuery('key1[=value&key2[]=value'); $vars = $url->getQueryVariables(); $url->setQueryVariables($vars); $newString = $url->getQuery(); var_export($newString); Expected result: ---------------- 'key1%5B=value&key2%5B%5D=value' Actual result: -------------- 'key1%5B=value&key2[]=value'

Comments