Skip to content

Commit

Permalink
Changin how HttpSocket parses query string parameters. Makes HttpSock…
Browse files Browse the repository at this point in the history
…et querystring parameter parsing more congruent with how PHP handles query string parameters in that it doesn't require urlencoded characters.

Tests added.
Fixes #156
  • Loading branch information
markstory committed Oct 30, 2009
1 parent a31a2d2 commit 17edec8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cake/libs/http_socket.php
Expand Up @@ -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;
Expand Down
22 changes: 22 additions & 0 deletions cake/tests/cases/libs/http_socket.test.php
Expand Up @@ -878,6 +878,28 @@ function testParseUri() {
'host' => 'www.google.com',
'port' => 8080,
));

$uri = $this->Socket->parseUri('http://www.cakephp.org/?param1=value1&param2=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&param2=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
Expand Down

0 comments on commit 17edec8

Please sign in to comment.