mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Merge branch 'master' into 2.6
Conflicts: lib/Cake/VERSION.txt
This commit is contained in:
commit
587f2da09e
7 changed files with 87 additions and 25 deletions
|
@ -24,12 +24,12 @@ canonicalize() {
|
|||
if [ -f "$NAME" ]
|
||||
then
|
||||
DIR=$(dirname -- "$NAME")
|
||||
NAME=$(cd -P "$DIR" && pwd -P)/$(basename -- "$NAME")
|
||||
NAME=$(cd -P "$DIR" > /dev/null && pwd -P)/$(basename -- "$NAME")
|
||||
fi
|
||||
while [ -h "$NAME" ]; do
|
||||
DIR=$(dirname -- "$NAME")
|
||||
SYM=$(readlink "$NAME")
|
||||
NAME=$(cd "$DIR" && cd $(dirname -- "$SYM") && pwd)/$(basename -- "$SYM")
|
||||
NAME=$(cd "$DIR" > /dev/null && cd $(dirname -- "$SYM") > /dev/null && pwd)/$(basename -- "$SYM")
|
||||
done
|
||||
echo "$NAME"
|
||||
}
|
||||
|
|
|
@ -713,12 +713,14 @@ class CakeSession {
|
|||
* @return void
|
||||
*/
|
||||
public static function renew() {
|
||||
if (session_id()) {
|
||||
if (session_id() || isset($_COOKIE[session_name()])) {
|
||||
setcookie(Configure::read('Session.cookie'), '', time() - 42000, self::$path);
|
||||
}
|
||||
session_regenerate_id(true);
|
||||
$id = session_id();
|
||||
if (!$id) {
|
||||
return;
|
||||
}
|
||||
if ($id || isset($_COOKIE[session_name()])) {
|
||||
setcookie(Configure::read('Session.cookie'), '', time() - 42000, self::$path);
|
||||
}
|
||||
session_regenerate_id(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -159,10 +159,12 @@ class HttpSocketResponse implements ArrayAccess {
|
|||
$this->raw = $message;
|
||||
$this->body = (string)substr($message, strlen($match[0]));
|
||||
|
||||
if (preg_match("/(.+) ([0-9]{3})\s*([^ ]*)\r\n/DU", $statusLine, $match)) {
|
||||
if (preg_match("/(.+) ([0-9]{3})(?:\s+(\w.+))?\s*\r\n/DU", $statusLine, $match)) {
|
||||
$this->httpVersion = $match[1];
|
||||
$this->code = $match[2];
|
||||
$this->reasonPhrase = $match[3];
|
||||
if (isset($match[3])) {
|
||||
$this->reasonPhrase = $match[3];
|
||||
}
|
||||
}
|
||||
|
||||
$this->headers = $this->_parseHeader($header);
|
||||
|
|
|
@ -1762,10 +1762,12 @@ class HttpSocketTest extends CakeTestCase {
|
|||
*/
|
||||
public function statusProvider() {
|
||||
return array(
|
||||
array('HTTP/1.1 200 '),
|
||||
array('HTTP/1.1 200 '),
|
||||
array('HTTP/1.1 200'),
|
||||
array('HTTP/1.1 200 OK', 'OK'),
|
||||
array('HTTP/1.1 200 ', '200'),
|
||||
array('HTTP/1.1 200 ', '200'),
|
||||
array('HTTP/1.1 200', '200'),
|
||||
array('HTTP/1.1 200 OK', '200', 'OK'),
|
||||
array('HTTP/1.1 404 Not Found', '404', 'Not Found'),
|
||||
array('HTTP/1.1 404 Not Found', '404', 'Not Found'),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1775,7 +1777,7 @@ class HttpSocketTest extends CakeTestCase {
|
|||
* @dataProvider statusProvider
|
||||
* @return void
|
||||
*/
|
||||
public function testResponseStatusParsing($status, $msg = '') {
|
||||
public function testResponseStatusParsing($status, $code, $msg = '') {
|
||||
$this->Socket->connected = true;
|
||||
$serverResponse = $status . "\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\n\r\n<h1>This is a test!</h1>";
|
||||
$this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse));
|
||||
|
@ -1785,7 +1787,7 @@ class HttpSocketTest extends CakeTestCase {
|
|||
$this->assertInstanceOf('HttpSocketResponse', $response);
|
||||
$expected = array(
|
||||
'http-version' => 'HTTP/1.1',
|
||||
'code' => '200',
|
||||
'code' => $code,
|
||||
'reason-phrase' => $msg
|
||||
);
|
||||
$this->assertEquals($expected, $response['status']);
|
||||
|
|
|
@ -1417,6 +1417,55 @@ class FormHelperTest extends CakeTestCase {
|
|||
$this->assertNotContains($expected, $result, 'URL is different');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure named parameters work correctly with hash generation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSecuredFormUrlWorksWithNamedParameter() {
|
||||
$this->Form->request['_Token'] = array('key' => 'testKey');
|
||||
|
||||
$expected = 'c890c5f041b1d83d1610dee8f52cd257df7ce618%3A';
|
||||
$this->Form->create('Address', array(
|
||||
'url' => array('controller' => 'articles', 'action' => 'view', 1, 'type' => 'red')
|
||||
));
|
||||
$result = $this->Form->secure();
|
||||
$this->assertContains($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that URL, HTML and identifer show up in their hashs.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSecuredFormUrlHasHtmlAndIdentifer() {
|
||||
$this->Form->request['_Token'] = array('key' => 'testKey');
|
||||
|
||||
$expected = 'ece0693fb1b19ca116133db1832ac29baaf41ce5%3A';
|
||||
$this->Form->create('Address', array(
|
||||
'url' => array(
|
||||
'controller' => 'articles',
|
||||
'action' => 'view',
|
||||
'?' => array(
|
||||
'page' => 1,
|
||||
'limit' => 10,
|
||||
'html' => '<>"',
|
||||
),
|
||||
'#' => 'result',
|
||||
),
|
||||
));
|
||||
$result = $this->Form->secure();
|
||||
$this->assertContains($expected, $result);
|
||||
|
||||
$this->Form->create('Address', array('url' => 'http://localhost/articles/view?page=1&limit=10&html=%3C%3E%22#result'));
|
||||
$result = $this->Form->secure();
|
||||
$this->assertContains($expected, $result, 'Full URL should only use path and query.');
|
||||
|
||||
$this->Form->create('Address', array('url' => '/articles/view?page=1&limit=10&html=%3C%3E%22#result'));
|
||||
$result = $this->Form->secure();
|
||||
$this->assertContains($expected, $result, 'URL path + query should work.');
|
||||
}
|
||||
|
||||
/**
|
||||
* testDisableSecurityUsingForm method
|
||||
*
|
||||
|
|
|
@ -56,7 +56,7 @@ class Inflector {
|
|||
'/$/' => 's',
|
||||
),
|
||||
'uninflected' => array(
|
||||
'.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox', '.*sheep', 'people'
|
||||
'.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox', '.*sheep', 'people', 'feedback'
|
||||
),
|
||||
'irregular' => array(
|
||||
'atlas' => 'atlases',
|
||||
|
@ -143,7 +143,7 @@ class Inflector {
|
|||
'/s$/i' => ''
|
||||
),
|
||||
'uninflected' => array(
|
||||
'.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox', '.*sheep', '.*ss'
|
||||
'.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox', '.*sheep', '.*ss', 'feedback'
|
||||
),
|
||||
'irregular' => array(
|
||||
'foes' => 'foe',
|
||||
|
|
|
@ -436,6 +436,7 @@ class FormHelper extends AppHelper {
|
|||
$this->requestType = strtolower($options['type']);
|
||||
|
||||
$action = $this->url($options['action']);
|
||||
$this->_lastAction($options['action']);
|
||||
unset($options['type'], $options['action']);
|
||||
|
||||
if (!$options['default']) {
|
||||
|
@ -467,13 +468,6 @@ class FormHelper extends AppHelper {
|
|||
$this->_introspectModel($model, 'fields');
|
||||
}
|
||||
|
||||
$this->_lastAction = $action;
|
||||
if (strpos($action, '://')) {
|
||||
$query = parse_url($action, PHP_URL_QUERY);
|
||||
$query = $query ? '?' . $query : '';
|
||||
$this->_lastAction = parse_url($action, PHP_URL_PATH) . $query;
|
||||
}
|
||||
|
||||
return $this->Html->useTag('form', $action, $htmlAttributes) . $append;
|
||||
}
|
||||
|
||||
|
@ -1828,7 +1822,7 @@ class FormHelper extends AppHelper {
|
|||
unset($options['target']);
|
||||
}
|
||||
|
||||
$this->_lastAction = $formUrl;
|
||||
$this->_lastAction($url);
|
||||
|
||||
$out = $this->Html->useTag('form', $formUrl, $formOptions);
|
||||
$out .= $this->Html->useTag('hidden', '_method', array(
|
||||
|
@ -3007,6 +3001,19 @@ class FormHelper extends AppHelper {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the last created form action.
|
||||
*
|
||||
* @var mixed
|
||||
* @return void
|
||||
*/
|
||||
protected function _lastAction($url) {
|
||||
$action = Router::url($url, true);
|
||||
$query = parse_url($action, PHP_URL_QUERY);
|
||||
$query = $query ? '?' . $query : '';
|
||||
$this->_lastAction = parse_url($action, PHP_URL_PATH) . $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set/Get inputDefaults for form elements
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue