diff options
author | David Flatz | 2018-06-18 15:18:16 +0200 |
---|---|---|
committer | David Flatz | 2018-06-18 15:19:48 +0200 |
commit | 3c94c414df60719fdcf8953531cc2eb7d417ed77 (patch) | |
tree | 37cf5490b385b400a20253f3f1286e6f75a5aa9e | |
parent | 6b0c87e5fad800ce625ff9ee47e27a2affd965b8 (diff) | |
download | itools-3c94c414df60719fdcf8953531cc2eb7d417ed77.tar.gz itools-3c94c414df60719fdcf8953531cc2eb7d417ed77.tar.bz2 itools-3c94c414df60719fdcf8953531cc2eb7d417ed77.zip |
urlencode keys of nested structures; this fixes illegal characters in urls
-rw-r--r-- | it_url.class | 2 | ||||
-rw-r--r-- | tests/U_tests.json | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/it_url.class b/it_url.class index 30a1e41..8a78075 100644 --- a/it_url.class +++ b/it_url.class @@ -721,7 +721,7 @@ static function _params($params, $keys = null, $finalize = true) foreach (it_url::_params($params[$key], null, false) as $value) { if (strlen($value)) - $result[] = it::replace(array('^([^=\[]*)' => $key . '[$1]'), $value); + $result[] = it::replace(array('^([^=\[]*)' => urlencode($key) . '[$1]'), $value); } } else if (strlen($params[$key])) diff --git a/tests/U_tests.json b/tests/U_tests.json index 591fdc9..e35ff9d 100644 --- a/tests/U_tests.json +++ b/tests/U_tests.json @@ -201,5 +201,11 @@ "args": ["app://settings"], "exp": "app://settings", "name": "U() do not add / for non-http url without path" + }, + + { + "args": ["/foo.html", {"<spam>": {"<spam>": "ham"}}], + "exp": "/foo.html?%3Cspam%3E%5B%3Cspam%3E%5D=ham", + "name": "U() urlencode keys of nested structures" } ] |