mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-18 07:29:51 +00:00
Merge branch '2.1' of https://github.com/cakephp/cakephp into 2.1-error-handler-bootstrap
This commit is contained in:
commit
2c55c7c193
4 changed files with 81 additions and 3 deletions
|
@ -768,7 +768,58 @@ class HttpSocket extends CakeSocket {
|
||||||
if (is_array($query)) {
|
if (is_array($query)) {
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
parse_str(ltrim($query, '?'), $parsedQuery);
|
|
||||||
|
if (is_array($query)) {
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
$parsedQuery = array();
|
||||||
|
|
||||||
|
if (is_string($query) && !empty($query)) {
|
||||||
|
$query = preg_replace('/^\?/', '', $query);
|
||||||
|
$items = explode('&', $query);
|
||||||
|
|
||||||
|
foreach ($items as $item) {
|
||||||
|
if (strpos($item, '=') !== false) {
|
||||||
|
list($key, $value) = explode('=', $item, 2);
|
||||||
|
} else {
|
||||||
|
$key = $item;
|
||||||
|
$value = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$key = urldecode($key);
|
||||||
|
$value = urldecode($value);
|
||||||
|
|
||||||
|
if (preg_match_all('/\[([^\[\]]*)\]/iUs', $key, $matches)) {
|
||||||
|
$subKeys = $matches[1];
|
||||||
|
$rootKey = substr($key, 0, strpos($key, '['));
|
||||||
|
if (!empty($rootKey)) {
|
||||||
|
array_unshift($subKeys, $rootKey);
|
||||||
|
}
|
||||||
|
$queryNode =& $parsedQuery;
|
||||||
|
|
||||||
|
foreach ($subKeys as $subKey) {
|
||||||
|
if (!is_array($queryNode)) {
|
||||||
|
$queryNode = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($subKey === '') {
|
||||||
|
$queryNode[] = array();
|
||||||
|
end($queryNode);
|
||||||
|
$subKey = key($queryNode);
|
||||||
|
}
|
||||||
|
$queryNode =& $queryNode[$subKey];
|
||||||
|
}
|
||||||
|
$queryNode = $value;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!isset($parsedQuery[$key])) {
|
||||||
|
$parsedQuery[$key] = $value;
|
||||||
|
} else {
|
||||||
|
$parsedQuery[$key] = (array)$parsedQuery[$key];
|
||||||
|
$parsedQuery[$key][] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return $parsedQuery;
|
return $parsedQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -240,7 +240,7 @@ class CakeRoute {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($route['_trailing_'])) {
|
if (isset($route['_trailing_'])) {
|
||||||
$route['pass'][] = $route['_trailing_'];
|
$route['pass'][] = rawurldecode($route['_trailing_']);
|
||||||
unset($route['_trailing_']);
|
unset($route['_trailing_']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1450,7 +1450,15 @@ class HttpSocketTest extends CakeTestCase {
|
||||||
),
|
),
|
||||||
'empty' => ''
|
'empty' => ''
|
||||||
);
|
);
|
||||||
$this->assertEquals($query, $expectedQuery);
|
$this->assertEquals($expectedQuery, $query);
|
||||||
|
|
||||||
|
$query = 'openid.ns=example.com&foo=bar&foo=baz';
|
||||||
|
$result = $this->Socket->parseQuery($query);
|
||||||
|
$expected = array(
|
||||||
|
'openid.ns' => 'example.com',
|
||||||
|
'foo' => array('bar', 'baz')
|
||||||
|
);
|
||||||
|
$this->assertEquals($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -857,4 +857,23 @@ class CakeRouteTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the /** special type on parsing - UTF8.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function testParseTrailingUTF8() {
|
||||||
|
$route = new CakeRoute( '/category/**', array('controller' => 'categories','action' => 'index'));
|
||||||
|
$result = $route->parse('/category/%D9%85%D9%88%D8%A8%D8%A7%DB%8C%D9%84');
|
||||||
|
$expected = array(
|
||||||
|
'controller' => 'categories',
|
||||||
|
'action' => 'index',
|
||||||
|
'pass' => array('موبایل'),
|
||||||
|
'named' => array()
|
||||||
|
);
|
||||||
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue