Skip to content

Commit aad8944

Browse files
committed
Fix: Blackholed request when POSTing to a URL with space
Eg: Actual Posted URL: /admin/settings/settings/prefix/Access%20Control $_GET value: /admin/settings/settings/prefix/Access_Control Since $unsetUrl differs, the $_GET value will get copied in to CakeRequest::$query, causing CakeRequest::here() to return: /admin/settings/settings/prefix/Access%20Control?%2Fadmin%2Fsettings%2Fsettings%2Fprefix%2FAccess_Control= This confuses SecurityComponent in the following line: https://github.com/cakephp/cakephp/blob/f23d811ff59c50ef278e98bb75f4ec1e7e54a5b3/lib/Cake/Controller/Component/SecurityComponent.php#L514
1 parent d0a22ad commit aad8944

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/Cake/Network/CakeRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ protected function _processGet() {
207207
$query = $_GET;
208208
}
209209

210-
$unsetUrl = '/' . str_replace('.', '_', urldecode($this->url));
210+
$unsetUrl = '/' . str_replace(array('.', ' '), '_', urldecode($this->url));
211211
unset($query[$unsetUrl]);
212212
unset($query[$this->base . $unsetUrl]);
213213
if (strpos($this->url, '?') !== false) {

lib/Cake/Test/Case/Network/CakeRequestTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2144,6 +2144,20 @@ public function testHere() {
21442144
$this->assertEquals('/posts/base_path/1/name:value?test=value', $result);
21452145
}
21462146

2147+
/**
2148+
* Test the here() with space in URL
2149+
*
2150+
* @return void
2151+
*/
2152+
public function testHereWithSpaceInUrl() {
2153+
Configure::write('App.base', '');
2154+
$_GET = array('/admin/settings/settings/prefix/Access_Control' => '');
2155+
$request = new CakeRequest('/admin/settings/settings/prefix/Access%20Control');
2156+
2157+
$result = $request->here();
2158+
$this->assertEquals('/admin/settings/settings/prefix/Access%20Control', $result);
2159+
}
2160+
21472161
/**
21482162
* Test the input() method.
21492163
*

0 commit comments

Comments
 (0)