mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge branch '2.0' into 2.1
Conflicts: lib/Cake/Network/Http/HttpSocket.php
This commit is contained in:
commit
c8eae93292
4 changed files with 44 additions and 2 deletions
|
@ -402,7 +402,7 @@ class HttpSocket extends CakeSocket {
|
||||||
}
|
}
|
||||||
$this->config['request']['cookies'][$Host] = array_merge($this->config['request']['cookies'][$Host], $this->response->cookies);
|
$this->config['request']['cookies'][$Host] = array_merge($this->config['request']['cookies'][$Host], $this->response->cookies);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->request['redirect'] && $this->response->isRedirect()) {
|
if($this->request['redirect'] && $this->response->isRedirect()) {
|
||||||
$request['uri'] = $this->response->getHeader('Location');
|
$request['uri'] = $this->response->getHeader('Location');
|
||||||
$request['redirect'] = is_int($this->request['redirect']) ? $this->request['redirect'] - 1 : $this->request['redirect'];
|
$request['redirect'] = is_int($this->request['redirect']) ? $this->request['redirect'] - 1 : $this->request['redirect'];
|
||||||
|
@ -655,6 +655,7 @@ class HttpSocket extends CakeSocket {
|
||||||
|
|
||||||
$uri['path'] = preg_replace('/^\//', null, $uri['path']);
|
$uri['path'] = preg_replace('/^\//', null, $uri['path']);
|
||||||
$uri['query'] = http_build_query($uri['query']);
|
$uri['query'] = http_build_query($uri['query']);
|
||||||
|
$uri['query'] = rtrim($uri['query'], '=');
|
||||||
$stripIfEmpty = array(
|
$stripIfEmpty = array(
|
||||||
'query' => '?%query',
|
'query' => '?%query',
|
||||||
'fragment' => '#%fragment',
|
'fragment' => '#%fragment',
|
||||||
|
|
|
@ -284,6 +284,7 @@ class CakeRoute {
|
||||||
$separatorIsPresent = strpos($param, $namedConfig['separator']) !== false;
|
$separatorIsPresent = strpos($param, $namedConfig['separator']) !== false;
|
||||||
if ((!isset($this->options['named']) || !empty($this->options['named'])) && $separatorIsPresent) {
|
if ((!isset($this->options['named']) || !empty($this->options['named'])) && $separatorIsPresent) {
|
||||||
list($key, $val) = explode($namedConfig['separator'], $param, 2);
|
list($key, $val) = explode($namedConfig['separator'], $param, 2);
|
||||||
|
$key = rawurldecode($key);
|
||||||
$val = rawurldecode($val);
|
$val = rawurldecode($val);
|
||||||
$hasRule = isset($rules[$key]);
|
$hasRule = isset($rules[$key]);
|
||||||
$passIt = (!$hasRule && !$greedy) || ($hasRule && !$this->_matchNamed($val, $rules[$key], $context));
|
$passIt = (!$hasRule && !$greedy) || ($hasRule && !$this->_matchNamed($val, $rules[$key], $context));
|
||||||
|
|
|
@ -554,7 +554,7 @@ class HttpSocketTest extends CakeTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the scheme + port keys
|
* Test the scheme + port keys
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testGetWithSchemeAndPort() {
|
public function testGetWithSchemeAndPort() {
|
||||||
|
@ -572,6 +572,26 @@ class HttpSocketTest extends CakeTestCase {
|
||||||
$this->assertContains('Host: cakephp.org:8080', $this->Socket->request['header']);
|
$this->assertContains('Host: cakephp.org:8080', $this->Socket->request['header']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test urls like http://cakephp.org/index.php?somestring without key/value pair for query
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testRequestWithStringQuery() {
|
||||||
|
$this->Socket->reset();
|
||||||
|
$request = array(
|
||||||
|
'uri' => array(
|
||||||
|
'scheme' => 'http',
|
||||||
|
'host' => 'cakephp.org',
|
||||||
|
'path' => 'index.php',
|
||||||
|
'query' => 'somestring'
|
||||||
|
),
|
||||||
|
'method' => 'GET'
|
||||||
|
);
|
||||||
|
$response = $this->Socket->request($request);
|
||||||
|
$this->assertContains("GET /index.php?somestring HTTP/1.1", $this->Socket->request['line']);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "*" asterisk character is only allowed for the following methods: OPTIONS.
|
* The "*" asterisk character is only allowed for the following methods: OPTIONS.
|
||||||
*
|
*
|
||||||
|
|
|
@ -403,6 +403,26 @@ class CakeRouteTest extends CakeTestCase {
|
||||||
$this->assertEquals('something else', $result['pass'][0]);
|
$this->assertEquals('something else', $result['pass'][0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensure that keys at named parameters are urldecoded
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testParseNamedKeyUrlDecode() {
|
||||||
|
Router::connectNamed(true);
|
||||||
|
$route = new CakeRoute('/:controller/:action/*', array('plugin' => null));
|
||||||
|
|
||||||
|
// checking /post/index/user[0]:a/user[1]:b
|
||||||
|
$result = $route->parse('/posts/index/user%5B0%5D:a/user%5B1%5D:b');
|
||||||
|
$this->assertArrayHasKey('user', $result['named']);
|
||||||
|
$this->assertEquals(array('a', 'b'), $result['named']['user']);
|
||||||
|
|
||||||
|
// checking /post/index/user[]:a/user[]:b
|
||||||
|
$result = $route->parse('/posts/index/user%5B%5D:a/user%5B%5D:b');
|
||||||
|
$this->assertArrayHasKey('user', $result['named']);
|
||||||
|
$this->assertEquals(array('a', 'b'), $result['named']['user']);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test that named params with null/false are excluded
|
* test that named params with null/false are excluded
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue