Merge branch 'master' into 2.7

This commit is contained in:
mark_story 2015-03-09 21:55:20 -04:00
commit 0b916cedbb
18 changed files with 105 additions and 29 deletions

View file

@ -333,15 +333,13 @@ class PaginatorComponent extends Component {
if (isset($this->settings[$alias])) { if (isset($this->settings[$alias])) {
$defaults = $this->settings[$alias]; $defaults = $this->settings[$alias];
} }
if (isset($defaults['limit']) && $defaults += array(
(empty($defaults['maxLimit']) || $defaults['limit'] > $defaults['maxLimit']) 'page' => 1,
) { 'limit' => 20,
$defaults['maxLimit'] = $defaults['limit']; 'maxLimit' => 100,
} 'paramType' => 'named'
return array_merge(
array('page' => 1, 'limit' => 20, 'maxLimit' => 100, 'paramType' => 'named'),
$defaults
); );
return $defaults;
} }
/** /**

View file

@ -874,11 +874,11 @@ class App {
), ),
'Vendor' => array( 'Vendor' => array(
'%s' . 'Vendor' . DS, '%s' . 'Vendor' . DS,
dirname(dirname(CAKE)) . DS . 'vendors' . DS, ROOT . DS . 'vendors' . DS,
), ),
'Plugin' => array( 'Plugin' => array(
APP . 'Plugin' . DS, APP . 'Plugin' . DS,
dirname(dirname(CAKE)) . DS . 'plugins' . DS ROOT . DS . 'plugins' . DS
) )
); );
} }

View file

@ -18,7 +18,6 @@ App::uses('CakeLog', 'Log');
App::uses('Dispatcher', 'Routing'); App::uses('Dispatcher', 'Routing');
App::uses('Router', 'Routing'); App::uses('Router', 'Routing');
App::uses('Set', 'Utility'); App::uses('Set', 'Utility');
App::uses('CakeLog', 'Log');
/** /**
* Object class provides a few generic methods used in several subclasses. * Object class provides a few generic methods used in several subclasses.

View file

@ -1941,9 +1941,8 @@ class Model extends Object implements CakeEventListener {
$this->_saveMulti($joined, $this->id, $db); $this->_saveMulti($joined, $this->id, $db);
} }
$this->whitelist = $_whitelist;
if (!$success) { if (!$success) {
$this->whitelist = $_whitelist;
return $success; return $success;
} }
@ -1964,6 +1963,7 @@ class Model extends Object implements CakeEventListener {
$this->_clearCache(); $this->_clearCache();
$this->validationErrors = array(); $this->validationErrors = array();
$this->whitelist = $_whitelist;
$this->data = false; $this->data = false;
return $success; return $success;

View file

@ -1336,7 +1336,7 @@ class CakeResponse {
'download' => null 'download' => null
); );
if (strpos($path, '..') !== false) { if (strpos($path, '..' . DS) !== false) {
throw new NotFoundException(__d( throw new NotFoundException(__d(
'cake_dev', 'cake_dev',
'The requested file contains `..` and will not be read.' 'The requested file contains `..` and will not be read.'

View file

@ -1435,7 +1435,7 @@ class CakeEmail {
$tmpLine .= $char; $tmpLine .= $char;
$tmpLineLength++; $tmpLineLength++;
if ($tmpLineLength === $wrapLength) { if ($tmpLineLength === $wrapLength) {
$nextChar = $line[$i + 1]; $nextChar = isset($line[$i + 1]) ? $line[$i + 1] : '';
if ($nextChar === ' ' || $nextChar === '<') { if ($nextChar === ' ' || $nextChar === '<') {
$formatted[] = trim($tmpLine); $formatted[] = trim($tmpLine);
$tmpLine = ''; $tmpLine = '';

View file

@ -853,7 +853,7 @@ class PaginatorComponentTest extends CakeTestCase {
'paramType' => 'named', 'paramType' => 'named',
); );
$result = $this->Paginator->mergeOptions('Post'); $result = $this->Paginator->mergeOptions('Post');
$expected = array('page' => 1, 'limit' => 200, 'maxLimit' => 200, 'paramType' => 'named'); $expected = array('page' => 1, 'limit' => 200, 'maxLimit' => 100, 'paramType' => 'named');
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$this->Paginator->settings = array( $this->Paginator->settings = array(
@ -872,7 +872,7 @@ class PaginatorComponentTest extends CakeTestCase {
'paramType' => 'named', 'paramType' => 'named',
); );
$result = $this->Paginator->mergeOptions('Post'); $result = $this->Paginator->mergeOptions('Post');
$expected = array('page' => 1, 'limit' => 500, 'maxLimit' => 150, 'paramType' => 'named'); $expected = array('page' => 1, 'limit' => 500, 'maxLimit' => 100, 'paramType' => 'named');
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }

View file

@ -387,6 +387,38 @@ class ModelWriteTest extends BaseModelTest {
$this->assertEquals($whitelist, $model->whitelist); $this->assertEquals($whitelist, $model->whitelist);
} }
/**
* Test save() resets the whitelist after afterSave
*
* @return void
*/
public function testSaveResetWhitelistOnSuccess() {
$this->loadFixtures('Post');
$callback = array($this, 'callbackForWhitelistReset');
$model = ClassRegistry::init('Post');
$model->whitelist = array('author_id', 'title', 'body');
$model->getEventManager()->attach($callback, 'Model.afterSave');
$data = array(
'title' => 'New post',
'body' => 'Post body',
'author_id' => 1
);
$result = $model->save($data);
$this->assertNotEmpty($result);
}
/**
* Callback for testing whitelist in afterSave
*
* @param Model $model The model having save called.
* @return void
*/
public function callbackForWhitelistReset($event) {
$expected = array('author_id', 'title', 'body', 'updated', 'created');
$this->assertEquals($expected, $event->subject()->whitelist);
}
/** /**
* testSaveWithCounterCache method * testSaveWithCounterCache method
* *

View file

@ -1170,6 +1170,7 @@ class CakeResponseTest extends CakeTestCase {
* test file with .. * test file with ..
* *
* @expectedException NotFoundException * @expectedException NotFoundException
* @expectedExceptionMessage The requested file contains `..` and will not be read.
* @return void * @return void
*/ */
public function testFileWithPathTraversal() { public function testFileWithPathTraversal() {
@ -1177,6 +1178,19 @@ class CakeResponseTest extends CakeTestCase {
$response->file('my/../cat.gif'); $response->file('my/../cat.gif');
} }
/**
* Although unlikely, a file may contain dots in its filename.
* This should be allowed, as long as the dots doesn't specify a path (../ or ..\)
*
* @expectedException NotFoundException
* @execptedExceptionMessageRegExp #The requested file .+my/Some..cat.gif was not found or not readable#
* @return void
*/
public function testFileWithDotsInFilename() {
$response = new CakeResponse();
$response->file('my/Some..cat.gif');
}
/** /**
* testFile method * testFile method
* *

View file

@ -2467,6 +2467,25 @@ HTML;
$this->assertEquals($expected, $result['message']); $this->assertEquals($expected, $result['message']);
} }
/**
* Test that really long lines don't cause errors.
*
* @return void
*/
public function testReallyLongLine() {
$this->CakeEmail->reset();
$this->CakeEmail->config(array('empty'));
$this->CakeEmail->transport('Debug');
$this->CakeEmail->from('cake@cakephp.org');
$this->CakeEmail->to('cake@cakephp.org');
$this->CakeEmail->subject('Wordwrap Test');
$this->CakeEmail->emailFormat('html');
$this->CakeEmail->template('long_line', null);
$result = $this->CakeEmail->send();
$this->assertContains('<a>', $result['message'], 'First bits are included');
$this->assertContains('x', $result['message'], 'Last byte are included');
}
/** /**
* CakeEmailTest::assertLineLengths() * CakeEmailTest::assertLineLengths()
* *

View file

@ -414,7 +414,7 @@ class CakeTestCaseTest extends CakeTestCase {
) )
), App::RESET); ), App::RESET);
$Post = $this->getMockForModel('Post'); $Post = $this->getMockForModel('Post');
$this->assertEquals('test', $Post->useDbConfig);
$this->assertInstanceOf('Post', $Post); $this->assertInstanceOf('Post', $Post);
$this->assertNull($Post->save(array())); $this->assertNull($Post->save(array()));
$this->assertNull($Post->find('all')); $this->assertNull($Post->find('all'));

View file

@ -72,13 +72,13 @@ class CakeTimeTest extends CakeTestCase {
*/ */
public function testToQuarter() { public function testToQuarter() {
$result = $this->Time->toQuarter('2007-12-25'); $result = $this->Time->toQuarter('2007-12-25');
$this->assertEquals(4, $result); $this->assertSame(4, $result);
$result = $this->Time->toQuarter('2007-9-25'); $result = $this->Time->toQuarter('2007-9-25');
$this->assertEquals(3, $result); $this->assertSame(3, $result);
$result = $this->Time->toQuarter('2007-3-25'); $result = $this->Time->toQuarter('2007-3-25');
$this->assertEquals(1, $result); $this->assertSame(1, $result);
$result = $this->Time->toQuarter('2007-3-25', true); $result = $this->Time->toQuarter('2007-3-25', true);
$this->assertEquals(array('2007-01-01', '2007-03-31'), $result); $this->assertEquals(array('2007-01-01', '2007-03-31'), $result);

View file

@ -782,7 +782,6 @@ class FormHelperTest extends CakeTestCase {
'type' => 'text', 'type' => 'text',
'name' => 'data[ValidateUser][cost_decimal]', 'name' => 'data[ValidateUser][cost_decimal]',
'id' => 'ValidateUserCostDecimal', 'id' => 'ValidateUserCostDecimal',
'maxlength' => 6,
)), )),
'/div' '/div'
); );

View file

@ -0,0 +1,14 @@
<?php
echo '<a>34567890123456789012345678901234567890123456789012345678901234567890' .
'12345678901234567890123456789012345678901234567890123456789012345678901234567890' .
'12345678901234567890123456789012345678901234567890123456789012345678901234567890' .
'12345678901234567890123456789012345678901234567890123456789012345678901234567890' .
'12345678901234567890123456789012345678901234567890123456789012345678901234567890' .
'12345678901234567890123456789012345678901234567890123456789012345678901234567890' .
'12345678901234567890123456789012345678901234567890123456789012345678901234567890' .
'12345678901234567890123456789012345678901234567890123456789012345678901234567890' .
'12345678901234567890123456789012345678901234567890123456789012345678901234567890' .
'12345678901234567890123456789012345678901234567890123456789012345678901234567890' .
'12345678901234567890123456789012345678901234567890123456789012345678901234567890' .
'12345678901234567890123456789012345678901234567890123456789012345678901234567890' .
'1234567890123456789012345678901234567890123456x';

View file

@ -732,12 +732,12 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
$mock = $this->getMock($name, $methods, array($config)); $mock = $this->getMock($name, $methods, array($config));
$availableDs = array_keys(ConnectionManager::enumConnectionObjects()); $availableDs = array_keys(ConnectionManager::enumConnectionObjects());
if ($mock->useDbConfig === 'default') {
$mock->useDbConfig = null;
$mock->setDataSource('test');
}
if ($mock->useDbConfig !== 'test' && in_array('test_' . $mock->useDbConfig, $availableDs)) { if ($mock->useDbConfig !== 'test' && in_array('test_' . $mock->useDbConfig, $availableDs)) {
$mock->setDataSource('test_' . $mock->useDbConfig); $mock->setDataSource('test_' . $mock->useDbConfig);
} else {
$mock->useDbConfig = 'test';
$mock->setDataSource('test');
} }
ClassRegistry::removeObject($name); ClassRegistry::removeObject($name);

View file

@ -575,12 +575,12 @@ class CakeTime {
* *
* @param int|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object * @param int|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
* @param bool $range if true returns a range in Y-m-d format * @param bool $range if true returns a range in Y-m-d format
* @return mixed 1, 2, 3, or 4 quarter of year or array if $range true * @return int|array 1, 2, 3, or 4 quarter of year or array if $range true
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::toQuarter * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::toQuarter
*/ */
public static function toQuarter($dateString, $range = false) { public static function toQuarter($dateString, $range = false) {
$time = self::fromString($dateString); $time = self::fromString($dateString);
$date = ceil(date('m', $time) / 3); $date = (int)ceil(date('m', $time) / 3);
if ($range === false) { if ($range === false) {
return $date; return $date;
} }

View file

@ -1287,6 +1287,7 @@ class FormHelper extends AppHelper {
isset($fieldDef['length']) && isset($fieldDef['length']) &&
is_scalar($fieldDef['length']) && is_scalar($fieldDef['length']) &&
$fieldDef['length'] < 1000000 && $fieldDef['length'] < 1000000 &&
$fieldDef['type'] !== 'decimal' &&
$options['type'] !== 'select' $options['type'] !== 'select'
); );
if ($autoLength && if ($autoLength &&

View file

@ -316,7 +316,7 @@ class TimeHelper extends AppHelper {
* *
* @param int|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object * @param int|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
* @param bool $range if true returns a range in Y-m-d format * @param bool $range if true returns a range in Y-m-d format
* @return mixed 1, 2, 3, or 4 quarter of year or array if $range true * @return int|array 1, 2, 3, or 4 quarter of year or array if $range true
* @see CakeTime::toQuarter() * @see CakeTime::toQuarter()
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting
*/ */