浏览代码

Merge branch 'master' into 2.6

Conflicts:
	lib/Cake/VERSION.txt
mark_story 12 年之前
父节点
当前提交
587f2da09e

+ 2 - 2
lib/Cake/Console/cake

@@ -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"
 }

+ 7 - 5
lib/Cake/Model/Datasource/CakeSession.php

@@ -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);
 	}
 
 /**

+ 4 - 2
lib/Cake/Network/Http/HttpSocketResponse.php

@@ -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);

+ 8 - 6
lib/Cake/Test/Case/Network/Http/HttpSocketTest.php

@@ -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']);

+ 49 - 0
lib/Cake/Test/Case/View/Helper/FormHelperTest.php

@@ -1418,6 +1418,55 @@ class FormHelperTest extends CakeTestCase {
 	}
 
 /**
+ * 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
  *
  * @return void

+ 2 - 2
lib/Cake/Utility/Inflector.php

@@ -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',

+ 15 - 8
lib/Cake/View/Helper/FormHelper.php

@@ -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(
@@ -3008,6 +3002,19 @@ class FormHelper extends AppHelper {
 	}
 
 /**
+ * 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
  *
  * @param array $defaults New default values