Merge branch '2.0' into 2.1

This commit is contained in:
mark_story 2012-02-18 11:22:18 -05:00
commit 20229eeb43
4 changed files with 44 additions and 2 deletions

View file

@ -185,7 +185,7 @@ class CakeRequest implements ArrayAccess {
$query = $_GET;
}
unset($query['/' . str_replace('.', '_', $this->url)]);
unset($query['/' . str_replace('.', '_', urldecode($this->url))]);
if (strpos($this->url, '?') !== false) {
list(, $querystr) = explode('?', $this->url);
parse_str($querystr, $queryArgs);

View file

@ -226,6 +226,12 @@ class CakeRoute {
$route[$key] = $value;
}
foreach ($this->keys as $key) {
if (isset($route[$key])) {
$route[$key] = rawurldecode($route[$key]);
}
}
if (isset($route['_args_'])) {
list($pass, $named) = $this->_parseArgs($route['_args_'], $route);
$route['pass'] = array_merge($route['pass'], $pass);

View file

@ -1120,6 +1120,20 @@ class CakeRequestTest extends CakeTestCase {
$this->assertEquals(array(), $request->query);
}
/**
* Test that a request with urlencoded bits in the main GET parameter are filtered out.
*
* @return void
*/
public function testGetParamWithUrlencodedElement() {
$_GET['/posts/add/∂∂'] = '';
$_SERVER['PHP_SELF'] = '/cake_dev/app/webroot/index.php';
$_SERVER['REQUEST_URI'] = '/cake_dev/posts/add/%E2%88%82%E2%88%82';
$request = new CakeRequest();
$this->assertEquals(array(), $request->query);
}
/**
* generator for environment configurations
*

View file

@ -508,6 +508,28 @@ class CakeRouteTest extends CakeTestCase {
$this->assertEquals($result['action'], 'index');
}
/**
* Test that :key elements are urldecoded
*
* @return void
*/
public function testParseUrlDecodeElements() {
$route = new Cakeroute(
'/:controller/:slug',
array('action' => 'view')
);
$route->compile();
$result = $route->parse('/posts/%E2%88%82%E2%88%82');
$this->assertEquals($result['controller'], 'posts');
$this->assertEquals($result['action'], 'view');
$this->assertEquals($result['slug'], '∂∂');
$result = $route->parse('/posts/∂∂');
$this->assertEquals($result['controller'], 'posts');
$this->assertEquals($result['action'], 'view');
$this->assertEquals($result['slug'], '∂∂');
}
/**
* test numerically indexed defaults, get appeneded to pass
*