- fix http_build_str(): urlencode [] brackets
authorMichael Wallner <mike@php.net>
Wed, 8 Mar 2006 21:52:55 +0000 (21:52 +0000)
committerMichael Wallner <mike@php.net>
Wed, 8 Mar 2006 21:52:55 +0000 (21:52 +0000)
http_url_api.c
package2.xml
tests/build_str_001.phpt

index cac64ec81ee880812cb10e186169363b50252855..cb0aeb5bd05d0eabcbfd018d71a4c30402d8e1ff 100644 (file)
@@ -385,14 +385,14 @@ PHP_HTTP_API STATUS _http_urlencode_hash_recursive(HashTable *ht, phpstr *str, c
                        phpstr_init(&new_prefix);
                        if (prefix && prefix_len) {
                                phpstr_append(&new_prefix, prefix, prefix_len);
-                               phpstr_appends(&new_prefix, "[");
+                               phpstr_appends(&new_prefix, "%5B");
                        }
                        
                        phpstr_append(&new_prefix, encoded_key, encoded_len);
                        efree(encoded_key);
                        
                        if (prefix && prefix_len) {
-                               phpstr_appends(&new_prefix, "]");
+                               phpstr_appends(&new_prefix, "%5D");
                        }
                        phpstr_fix(&new_prefix);
                }
index 499d7904a5923107d4c7c70409a6c8bdc4a144b5..a62cff82989a46b42ec3f216d48d370360f50a1e 100644 (file)
@@ -47,6 +47,7 @@ HttpResponse
  <license>BSD, revised</license>
  <notes><![CDATA[
 * Fixed possible crash in HttpQueryString if the SAPI does not have a treat_data function registered.
+* Fixed http_build_str() to urlencode brackets ("[]").
 ]]></notes>
  <contents>
   <dir name="/">
index 9bd0f40294599003aefdf0d79a93d01f798613fe..8aeafcc06143bbcbf7ac0134d92c4931b1308f30 100644 (file)
@@ -8,23 +8,23 @@ include 'skip.inc';
 <?php
 echo "-TEST\n";
 
-parse_str($s = "a=b", $q);
-var_dump($s === http_build_str($q, null, "&"));
+parse_str("a=b", $q);
+echo http_build_str($q, null, "&"), "\n";
 
-parse_str($s = "a=b&c[0]=1", $q);
-var_dump($s === http_build_str($q, null, "&"));
+parse_str("a=b&c[0]=1", $q);
+echo http_build_str($q, null, "&"), "\n";
 
-parse_str($s = "a=b&c[0]=1&d[e]=f", $q);
-var_dump($s === http_build_str($q, null, "&"));
+parse_str("a=b&c[0]=1&d[e]=f", $q);
+echo http_build_str($q, null, "&"), "\n";
 
-var_dump("foo[0]=1&foo[1]=2&foo[2][0]=3" === http_build_str(array(1,2,array(3)), "foo", "&"));
+echo http_build_str(array(1,2,array(3)), "foo", "&"), "\n";
 
 echo "Done\n";
 ?>
 --EXPECTF--
 %sTEST
-bool(true)
-bool(true)
-bool(true)
-bool(true)
+a=b
+a=b&c%5B0%5D=1
+a=b&c%5B0%5D=1&d%5Be%5D=f
+foo%5B0%5D=1&foo%5B1%5D=2&foo%5B2%5D%5B0%5D=3
 Done