From 17edec84607ad1a347113278bddc3eed988c5e21 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 29 Oct 2009 20:14:36 -0400 Subject: [PATCH] Changin how HttpSocket parses query string parameters. Makes HttpSocket querystring parameter parsing more congruent with how PHP handles query string parameters in that it doesn't require urlencoded characters. Tests added. Fixes #156 --- cake/libs/http_socket.php | 2 +- cake/tests/cases/libs/http_socket.test.php | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index 76d12d7102a..793618ece27 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -672,7 +672,7 @@ function parseQuery($query) { foreach ($items as $item) { if (strpos($item, '=') !== false) { - list($key, $value) = explode('=', $item); + list($key, $value) = explode('=', $item, 2); } else { $key = $item; $value = null; diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php index b3fa948b14d..2dbc193d969 100644 --- a/cake/tests/cases/libs/http_socket.test.php +++ b/cake/tests/cases/libs/http_socket.test.php @@ -878,6 +878,28 @@ function testParseUri() { 'host' => 'www.google.com', 'port' => 8080, )); + + $uri = $this->Socket->parseUri('http://www.cakephp.org/?param1=value1¶m2=value2%3Dvalue3'); + $this->assertIdentical($uri, array( + 'scheme' => 'http', + 'host' => 'www.cakephp.org', + 'path' => '/', + 'query' => array( + 'param1' => 'value1', + 'param2' => 'value2=value3' + ) + )); + + $uri = $this->Socket->parseUri('http://www.cakephp.org/?param1=value1¶m2=value2=value3'); + $this->assertIdentical($uri, array( + 'scheme' => 'http', + 'host' => 'www.cakephp.org', + 'path' => '/', + 'query' => array( + 'param1' => 'value1', + 'param2' => 'value2=value3' + ) + )); } /** * Tests that HttpSocket::buildUri can turn all kinds of uri arrays (and strings) into fully or partially qualified URI's