Browse Source

Merge branch 'master' into 2.4

ADmad 13 years ago
parent
commit
fb86859585

+ 8 - 4
lib/Cake/Console/Command/Task/ProjectTask.php

@@ -404,15 +404,19 @@ class ProjectTask extends AppShell {
 		}
 		if ($this->interactive) {
 			$this->hr();
-			$this->out(__d('cake_console', 'You need to enable Configure::write(\'Routing.prefixes\',array(\'admin\')) in /app/Config/core.php to use prefix routing.'));
+			$this->out(__d('cake_console', 'You need to enable %s in %s to use prefix routing.',
+					'Configure::write(\'Routing.prefixes\', array(\'admin\'))',
+					'/app/Config/core.php'));
 			$this->out(__d('cake_console', 'What would you like the prefix route to be?'));
-			$this->out(__d('cake_console', 'Example: www.example.com/admin/controller'));
+			$this->out(__d('cake_console', 'Example: %s', 'www.example.com/admin/controller'));
 			while (!$admin) {
 				$admin = $this->in(__d('cake_console', 'Enter a routing prefix:'), null, 'admin');
 			}
 			if ($this->cakeAdmin($admin) !== true) {
-				$this->out(__d('cake_console', '<error>Unable to write to</error> /app/Config/core.php.'));
-				$this->out(__d('cake_console', 'You need to enable Configure::write(\'Routing.prefixes\',array(\'admin\')) in /app/Config/core.php to use prefix routing.'));
+				$this->out(__d('cake_console', '<error>Unable to write to</error> %s.', '/app/Config/core.php'));
+				$this->out(__d('cake_console', 'You need to enable %s in %s to use prefix routing.',
+					'Configure::write(\'Routing.prefixes\', array(\'admin\'))',
+					'/app/Config/core.php'));
 				$this->_stop();
 			}
 			return $admin . '_';

+ 3 - 0
lib/Cake/Controller/Component/RequestHandlerComponent.php

@@ -244,6 +244,9 @@ class RequestHandlerComponent extends Component {
 		if (!$this->request->is('ajax')) {
 			return;
 		}
+		if (empty($url)) {
+			return;
+		}
 		$_SERVER['REQUEST_METHOD'] = 'GET';
 		foreach ($_POST as $key => $val) {
 			unset($_POST[$key]);

+ 1 - 1
lib/Cake/I18n/I18n.php

@@ -590,7 +590,7 @@ class I18n {
 		$string = $string[1];
 		if (substr($string, 0, 2) === $this->_escape . 'x') {
 			$delimiter = $this->_escape . 'x';
-			return implode('', array_map('chr', array_map('hexdec',array_filter(explode($delimiter, $string)))));
+			return implode('', array_map('chr', array_map('hexdec', array_filter(explode($delimiter, $string)))));
 		}
 		if (substr($string, 0, 2) === $this->_escape . 'd') {
 			$delimiter = $this->_escape . 'd';

+ 1 - 1
lib/Cake/Network/Email/CakeEmail.php

@@ -1263,7 +1263,7 @@ class CakeEmail {
 				$formatted[] = '';
 				continue;
 			}
-			if (!preg_match('/\<[a-z]/i', $line)) {
+			if (!preg_match('/<[a-z]+.+>/i', $line)) {
 				$formatted = array_merge(
 					$formatted,
 					explode("\n", wordwrap($line, $wrapLength, "\n"))

+ 1 - 1
lib/Cake/Routing/Filter/AssetDispatcher.php

@@ -124,7 +124,7 @@ class AssetDispatcher extends DispatcherFilter {
 		}
 
 		$plugin = Inflector::camelize($parts[0]);
-		if (CakePlugin::loaded($plugin)) {
+		if ($plugin && CakePlugin::loaded($plugin)) {
 			unset($parts[0]);
 			$fileFragment = urldecode(implode(DS, $parts));
 			$pluginWebroot = CakePlugin::path($plugin) . 'webroot' . DS;

+ 17 - 0
lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php

@@ -412,6 +412,23 @@ class RequestHandlerComponentTest extends CakeTestCase {
 	}
 
 /**
+ * test that redirects with ajax and no url don't do anything.
+ *
+ * @return void
+ */
+	public function testAjaxRedirectWithNoUrl() {
+		$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
+		$this->Controller->response = $this->getMock('CakeResponse');
+
+		$this->Controller->response->expects($this->never())
+			->method('body');
+
+		$this->RequestHandler->initialize($this->Controller);
+		$this->RequestHandler->startup($this->Controller);
+		$this->assertNull($this->RequestHandler->beforeRedirect($this->Controller, null));
+	}
+
+/**
  * testRenderAs method
  *
  * @return void

+ 3 - 3
lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php

@@ -1046,7 +1046,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
 			array($modelClass => array('name' => '1.2')));
 		$this->assertEquals($children, $expects);
 
-		$topNodes = $this->Tree->children(false, true,array('name'));
+		$topNodes = $this->Tree->children(false, true, array('name'));
 		$expects = array(array($modelClass => array('name' => '1. Root')),
 			array($modelClass => array('name' => '1.1')));
 		$this->assertEquals($topNodes, $expects);
@@ -1077,7 +1077,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
 		$this->assertEquals($initialCount, $laterCount);
 		$this->assertEquals($initialTopNodes, $laterTopNodes);
 
-		$topNodes = $this->Tree->children(false, true,array('name'));
+		$topNodes = $this->Tree->children(false, true, array('name'));
 		$expects = array(array($modelClass => array('name' => '1.1')),
 			array($modelClass => array('name' => '1.2')),
 			array($modelClass => array('name' => '1. Root')));
@@ -1148,7 +1148,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
 		);
 		$this->assertEquals($children, $expects);
 
-		$topNodes = $this->Tree->children(false, true,array('name'));
+		$topNodes = $this->Tree->children(false, true, array('name'));
 		$expects = array(array($modelClass => array('name' => '1. Root')));
 		$this->assertEquals($topNodes, $expects);
 

+ 7 - 7
lib/Cake/Test/Case/Model/ModelReadTest.php

@@ -232,7 +232,7 @@ class ModelReadTest extends BaseModelTest {
 			array('Product' => array('type' => 'Music'), array('price' => 4)),
 			array('Product' => array('type' => 'Toy'), array('price' => 3))
 		);
-		$result = $Product->find('all',array(
+		$result = $Product->find('all', array(
 			'fields' => array('Product.type', 'MIN(Product.price) as price'),
 			'group' => 'Product.type',
 			'order' => 'Product.type ASC'
@@ -7717,34 +7717,34 @@ class ModelReadTest extends BaseModelTest {
 			$this->assertFalse((bool)$result['Author']['false']);
 		}
 
-		$result = $Post->find('first',array('fields' => array('author_id')));
+		$result = $Post->find('first', array('fields' => array('author_id')));
 		$this->assertFalse(isset($result['Post']['two']));
 		$this->assertFalse(isset($result['Author']['false']));
 
-		$result = $Post->find('first',array('fields' => array('author_id', 'two')));
+		$result = $Post->find('first', array('fields' => array('author_id', 'two')));
 		$this->assertEquals(2, $result['Post']['two']);
 		$this->assertFalse(isset($result['Author']['false']));
 
-		$result = $Post->find('first',array('fields' => array('two')));
+		$result = $Post->find('first', array('fields' => array('two')));
 		$this->assertEquals(2, $result['Post']['two']);
 
 		$Post->id = 1;
 		$result = $Post->field('two');
 		$this->assertEquals(2, $result);
 
-		$result = $Post->find('first',array(
+		$result = $Post->find('first', array(
 			'conditions' => array('two' => 2),
 			'limit' => 1
 		));
 		$this->assertEquals(2, $result['Post']['two']);
 
-		$result = $Post->find('first',array(
+		$result = $Post->find('first', array(
 			'conditions' => array('two <' => 3),
 			'limit' => 1
 		));
 		$this->assertEquals(2, $result['Post']['two']);
 
-		$result = $Post->find('first',array(
+		$result = $Post->find('first', array(
 			'conditions' => array('NOT' => array('two >' => 3)),
 			'limit' => 1
 		));

+ 3 - 3
lib/Cake/Test/Case/Model/ModelWriteTest.php

@@ -396,7 +396,7 @@ class ModelWriteTest extends BaseModelTest {
 		$data[$Post->alias]['user_id'] = 301;
 		$Post->save($data);
 
-		$users = $User->find('all',array('order' => 'User.id'));
+		$users = $User->find('all', array('order' => 'User.id'));
 		$this->assertEquals(1, $users[0]['User']['post_count']);
 		$this->assertEquals(2, $users[1]['User']['post_count']);
 	}
@@ -423,7 +423,7 @@ class ModelWriteTest extends BaseModelTest {
 		$data[$Post->alias]['uid'] = 301;
 		$Post->save($data);
 
-		$users = $User->find('all',array('order' => 'User.uid'));
+		$users = $User->find('all', array('order' => 'User.uid'));
 		$this->assertEquals(1, $users[0]['User']['post_count']);
 		$this->assertEquals(2, $users[1]['User']['post_count']);
 	}
@@ -551,7 +551,7 @@ class ModelWriteTest extends BaseModelTest {
 		));
 		$data[$Post->alias]['user_id'] = 301;
 		$Post->save($data);
-		$result = $User->find('all',array('order' => 'User.id'));
+		$result = $User->find('all', array('order' => 'User.id'));
 		$this->assertEquals(2, $result[0]['User']['post_count']);
 		$this->assertEquals(1, $result[1]['User']['posts_published']);
 	}

+ 52 - 0
lib/Cake/Test/Case/Network/Email/CakeEmailTest.php

@@ -1651,6 +1651,58 @@ class CakeEmailTest extends CakeTestCase {
 		$this->assertContains('ってテーブルを作ってやってたらう', $result['message']);
 	}
 
+	public function testWrapLongLine() {
+		$message = '<a href="http://cakephp.org">' . str_repeat('x', CakeEmail::LINE_LENGTH_MUST) . "</a>";
+
+		$this->CakeEmail->reset();
+		$this->CakeEmail->transport('Debug');
+		$this->CakeEmail->from('cake@cakephp.org');
+		$this->CakeEmail->to('cake@cakephp.org');
+		$this->CakeEmail->subject('Wordwrap Test');
+		$this->CakeEmail->config(array('empty'));
+		$result = $this->CakeEmail->send($message);
+		$expected = "<a\r\n" . 'href="http://cakephp.org">' . str_repeat('x', CakeEmail::LINE_LENGTH_MUST) . "\r\n</a>\r\n\r\n";
+		$this->assertEquals($expected, $result['message']);
+	}
+
+	public function testWrapIncludeTag() {
+		$message = '<a href="http://cakephp.org">CakePHP</a>';
+
+		$this->CakeEmail->reset();
+		$this->CakeEmail->transport('Debug');
+		$this->CakeEmail->from('cake@cakephp.org');
+		$this->CakeEmail->to('cake@cakephp.org');
+		$this->CakeEmail->subject('Wordwrap Test');
+		$this->CakeEmail->config(array('empty'));
+		$result = $this->CakeEmail->send($message);
+		$expected = "{$message}\r\n\r\n";
+		$this->assertEquals($expected, $result['message']);
+
+		$message = 'foo<bar';
+
+		$result = $this->CakeEmail->send($message);
+		$expected = "{$message}\r\n\r\n";
+		$this->assertEquals($expected, $result['message']);
+	}
+
+	public function testWrapForJapaneseEncoding() {
+		$this->skipIf(!function_exists('mb_convert_encoding'));
+
+		$message = mb_convert_encoding('受け付けました', 'iso-2022-jp', 'UTF-8');
+
+		$this->CakeEmail->reset();
+		$this->CakeEmail->transport('Debug');
+		$this->CakeEmail->from('cake@cakephp.org');
+		$this->CakeEmail->to('cake@cakephp.org');
+		$this->CakeEmail->subject('Wordwrap Test');
+		$this->CakeEmail->config(array('empty'));
+		$this->CakeEmail->charset('iso-2022-jp');
+		$this->CakeEmail->headerCharset('iso-2022-jp');
+		$result = $this->CakeEmail->send($message);
+		$expected = "{$message}\r\n\r\n";
+		$this->assertEquals($expected, $result['message']);
+	}
+
 /**
  * Tests that the body is encoded using the configured charset
  *

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

@@ -1076,7 +1076,7 @@ class HttpSocketTest extends CakeTestCase {
 				'pass' => 'hunter2'
 			)
 		));
-		$this->assertEquals($socket->request['auth'],array('Basic' => array('user' => 'joel', 'pass' => 'hunter2')));
+		$this->assertEquals($socket->request['auth'], array('Basic' => array('user' => 'joel', 'pass' => 'hunter2')));
 		$this->assertTrue(strpos($socket->request['header'], 'Authorization: Basic am9lbDpodW50ZXIy') !== false);
 	}
 

+ 17 - 0
lib/Cake/Test/Case/Routing/Filter/AssetDispatcherTest.php

@@ -121,4 +121,21 @@ class AssetDispatcherTest extends CakeTestCase {
 		$this->assertSame($response, $filter->beforeDispatch($event));
 		$this->assertEquals($time->format('D, j M Y H:i:s') . ' GMT', $response->modified());
 	}
+
+/**
+ * Test that no exceptions are thrown for //index.php type urls.
+ *
+ * @return void
+ */
+	public function test404OnDoubleSlash() {
+		$filter = new AssetDispatcher();
+
+		$response = $this->getMock('CakeResponse', array('_sendHeader'));
+		$request = new CakeRequest('//index.php');
+		$event = new CakeEvent('Dispatcher.beforeRequest', $this, compact('request', 'response'));
+
+		$this->assertNull($filter->beforeDispatch($event));
+		$this->assertFalse($event->isStopped());
+	}
+
 }

+ 6 - 6
lib/Cake/Test/Case/Utility/SetTest.php

@@ -282,15 +282,15 @@ class SetTest extends CakeTestCase {
 		$this->assertEquals($a, $b);
 
 		$a = array(
-			array(7,6,4),
-			array(3,4,5),
-			array(3,2,array(1,1,1)),
+			array(7, 6, 4),
+			array(3, 4, 5),
+			array(3, 2, array(1, 1, 1)),
 		);
 
 		$b = array(
-			array(3,2,array(1,1,1)),
-			array(3,4,5),
-			array(7,6,4),
+			array(3, 2, array(1, 1, 1)),
+			array(3, 4, 5),
+			array(7, 6, 4),
 		);
 
 		$a = Set::sort($a, '{n}', 'asc');

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

@@ -3472,10 +3472,10 @@ class FormHelperTest extends CakeTestCase {
 		$this->Form->create('ValidateProfile');
 		$ValidateProfile = ClassRegistry::getObject('ValidateProfile');
 		$ValidateProfile->validationErrors['city'] = array('required<br>');
-		$result = $this->Form->input('city',array('error' => array('attributes' => array('escape' => true))));
+		$result = $this->Form->input('city', array('error' => array('attributes' => array('escape' => true))));
 		$this->assertRegExp('/required&lt;br&gt;/', $result);
 
-		$result = $this->Form->input('city',array('error' => array('attributes' => array('escape' => false))));
+		$result = $this->Form->input('city', array('error' => array('attributes' => array('escape' => false))));
 		$this->assertRegExp('/required<br>/', $result);
 	}
 
@@ -8474,7 +8474,7 @@ class FormHelperTest extends CakeTestCase {
 		);
 		$this->assertTags($result, $expected);
 
-		$result = $this->Form->input('ValidateProfile.1.ValidateItem.2.created',array('empty' => true));
+		$result = $this->Form->input('ValidateProfile.1.ValidateItem.2.created', array('empty' => true));
 		$expected = array(
 			'div' => array('class' => 'input date'),
 			'label' => array('for' => 'ValidateProfile1ValidateItem2CreatedMonth'),