diff --git a/.htaccess b/.htaccess
index f23dbaf66..2ac5e0e7a 100644
--- a/.htaccess
+++ b/.htaccess
@@ -1,5 +1,5 @@
- RewriteEngine on
- RewriteRule ^$ app/webroot/ [L]
- RewriteRule (.*) app/webroot/$1 [L]
+ RewriteEngine on
+ RewriteRule ^$ app/webroot/ [L]
+ RewriteRule (.*) app/webroot/$1 [L]
\ No newline at end of file
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 5bb121179..c991e2460 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -63,6 +63,10 @@ Check the [cakephp-codesniffer](https://github.com/cakephp/cakephp-codesniffer)
repository to setup the CakePHP standard. The [README](https://github.com/cakephp/cakephp-codesniffer/blob/master/README.md) contains installation info
for the sniff and phpcs.
+## Reporting a Security Issue
+
+If you've found a security related issue in CakePHP, please don't open an issue in GitHub. Instead contact us at security@cakephp.org. For more information on how we handle security issues, [see the CakePHP Security Issue Process](http://book.cakephp.org/2.0/en/contributing/tickets.html#reporting-security-issues).
+
# Additional Resources
* [CakePHP coding standards](http://book.cakephp.org/2.0/en/contributing/cakephp-coding-conventions.html)
diff --git a/app/.htaccess b/app/.htaccess
index fc3aac4b2..128e7871b 100644
--- a/app/.htaccess
+++ b/app/.htaccess
@@ -1,5 +1,5 @@
- RewriteEngine on
- RewriteRule ^$ webroot/ [L]
- RewriteRule (.*) webroot/$1 [L]
+ RewriteEngine on
+ RewriteRule ^$ webroot/ [L]
+ RewriteRule (.*) webroot/$1 [L]
\ No newline at end of file
diff --git a/app/webroot/.htaccess b/app/webroot/.htaccess
index 1f19e4c06..1d499ba73 100644
--- a/app/webroot/.htaccess
+++ b/app/webroot/.htaccess
@@ -1,6 +1,6 @@
- RewriteEngine On
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteRule ^ index.php [L]
+ RewriteEngine On
+ RewriteCond %{REQUEST_FILENAME} !-d
+ RewriteCond %{REQUEST_FILENAME} !-f
+ RewriteRule ^ index.php [L]
diff --git a/lib/Cake/Cache/Engine/XcacheEngine.php b/lib/Cake/Cache/Engine/XcacheEngine.php
index 9c1855605..97c851818 100644
--- a/lib/Cake/Cache/Engine/XcacheEngine.php
+++ b/lib/Cake/Cache/Engine/XcacheEngine.php
@@ -44,7 +44,7 @@ class XcacheEngine extends CacheEngine {
* @return bool True if the engine has been successfully initialized, false if not
*/
public function init($settings = array()) {
- if (php_sapi_name() !== 'cli') {
+ if (PHP_SAPI !== 'cli') {
parent::init(array_merge(array(
'engine' => 'Xcache',
'prefix' => Inflector::slug(APP_DIR) . '_',
diff --git a/lib/Cake/Console/Command/Task/FixtureTask.php b/lib/Cake/Console/Command/Task/FixtureTask.php
index b20c22b4b..05caa4629 100644
--- a/lib/Cake/Console/Command/Task/FixtureTask.php
+++ b/lib/Cake/Console/Command/Task/FixtureTask.php
@@ -414,19 +414,26 @@ class FixtureTask extends BakeTask {
* @return array Array of records.
*/
protected function _getRecordsFromTable($modelName, $useTable = null) {
+ $modelObject = new Model(array('name' => $modelName, 'table' => $useTable, 'ds' => $this->connection));
if ($this->interactive) {
$condition = null;
$prompt = __d('cake_console', "Please provide a SQL fragment to use as conditions\nExample: WHERE 1=1");
while (!$condition) {
$condition = $this->in($prompt, null, 'WHERE 1=1');
}
+
+ $recordsFound = $modelObject->find('count', array(
+ 'conditions' => $condition,
+ 'recursive' => -1,
+ ));
+
$prompt = __d('cake_console', "How many records do you want to import?");
- $recordCount = $this->in($prompt, null, 10);
+ $recordCount = $this->in($prompt, null, ($recordsFound < 10 ) ? $recordsFound : 10);
} else {
$condition = 'WHERE 1=1';
$recordCount = (isset($this->params['count']) ? $this->params['count'] : 10);
}
- $modelObject = new Model(array('name' => $modelName, 'table' => $useTable, 'ds' => $this->connection));
+
$records = $modelObject->find('all', array(
'conditions' => $condition,
'recursive' => -1,
diff --git a/lib/Cake/Console/Templates/default/views/form.ctp b/lib/Cake/Console/Templates/default/views/form.ctp
index b7dad3cee..4a21aabe3 100644
--- a/lib/Cake/Console/Templates/default/views/form.ctp
+++ b/lib/Cake/Console/Templates/default/views/form.ctp
@@ -44,7 +44,7 @@
- - Form->postLink(__('Delete'), array('action' => 'delete', \$this->Form->value('{$modelClass}.{$primaryKey}')), array(), __('Are you sure you want to delete # %s?', \$this->Form->value('{$modelClass}.{$primaryKey}'))); ?>"; ?>
+ - Form->postLink(__('Delete'), array('action' => 'delete', \$this->Form->value('{$modelClass}.{$primaryKey}')), array('confirm' => __('Are you sure you want to delete # %s?', \$this->Form->value('{$modelClass}.{$primaryKey}')))); ?>"; ?>
- Html->link(__('List " . $pluralHumanName . "'), array('action' => 'index')); ?>"; ?>
Html->link(__('Edit " . $singularHumanName ."'), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> \n";
- echo "\t\t- Form->postLink(__('Delete " . $singularHumanName . "'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), array(), __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>
\n";
+ echo "\t\t- Form->postLink(__('Delete " . $singularHumanName . "'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), array('confirm' => __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}']))); ?>
\n";
echo "\t\t- Html->link(__('List " . $pluralHumanName . "'), array('action' => 'index')); ?>
\n";
echo "\t\t- Html->link(__('New " . $singularHumanName . "'), array('action' => 'add')); ?>
\n";
@@ -117,7 +117,7 @@ echo "\t\n";
echo "\t\t\t\tHtml->link(__('View'), array('controller' => '{$details['controller']}', 'action' => 'view', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
echo "\t\t\t\tHtml->link(__('Edit'), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
- echo "\t\t\t\tForm->postLink(__('Delete'), array('controller' => '{$details['controller']}', 'action' => 'delete', \${$otherSingularVar}['{$details['primaryKey']}']), array(), __('Are you sure you want to delete # %s?', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
+ echo "\t\t\t\tForm->postLink(__('Delete'), array('controller' => '{$details['controller']}', 'action' => 'delete', \${$otherSingularVar}['{$details['primaryKey']}']), array('confirm' => __('Are you sure you want to delete # %s?', \${$otherSingularVar}['{$details['primaryKey']}']))); ?>\n";
echo "\t\t\t\n";
echo "\t\t\n";
diff --git a/lib/Cake/Console/Templates/skel/.htaccess b/lib/Cake/Console/Templates/skel/.htaccess
index fc3aac4b2..128e7871b 100644
--- a/lib/Cake/Console/Templates/skel/.htaccess
+++ b/lib/Cake/Console/Templates/skel/.htaccess
@@ -1,5 +1,5 @@
- RewriteEngine on
- RewriteRule ^$ webroot/ [L]
- RewriteRule (.*) webroot/$1 [L]
+ RewriteEngine on
+ RewriteRule ^$ webroot/ [L]
+ RewriteRule (.*) webroot/$1 [L]
\ No newline at end of file
diff --git a/lib/Cake/Console/Templates/skel/webroot/.htaccess b/lib/Cake/Console/Templates/skel/webroot/.htaccess
index 1f19e4c06..1d499ba73 100644
--- a/lib/Cake/Console/Templates/skel/webroot/.htaccess
+++ b/lib/Cake/Console/Templates/skel/webroot/.htaccess
@@ -1,6 +1,6 @@
- RewriteEngine On
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteRule ^ index.php [L]
+ RewriteEngine On
+ RewriteCond %{REQUEST_FILENAME} !-d
+ RewriteCond %{REQUEST_FILENAME} !-f
+ RewriteRule ^ index.php [L]
diff --git a/lib/Cake/Console/Templates/skel/webroot/index.php b/lib/Cake/Console/Templates/skel/webroot/index.php
index 4b67fafa4..e546e52ca 100644
--- a/lib/Cake/Console/Templates/skel/webroot/index.php
+++ b/lib/Cake/Console/Templates/skel/webroot/index.php
@@ -77,7 +77,7 @@ if (!defined('WWW_ROOT')) {
}
// for built-in server
-if (php_sapi_name() === 'cli-server') {
+if (PHP_SAPI === 'cli-server') {
if ($_SERVER['REQUEST_URI'] !== '/' && file_exists(WWW_ROOT . $_SERVER['PHP_SELF'])) {
return false;
}
diff --git a/lib/Cake/Controller/Component/EmailComponent.php b/lib/Cake/Controller/Component/EmailComponent.php
index 799baaca8..d89099f7e 100644
--- a/lib/Cake/Controller/Component/EmailComponent.php
+++ b/lib/Cake/Controller/Component/EmailComponent.php
@@ -309,7 +309,8 @@ class EmailComponent extends Component {
$lib->readReceipt($this->_formatAddresses((array)$this->readReceipt));
}
- $lib->subject($this->subject)->messageID($this->messageId);
+ $lib->subject($this->subject);
+ $lib->messageID($this->messageId);
$lib->helpers($this->_controller->helpers);
$headers = array('X-Mailer' => $this->xMailer);
diff --git a/lib/Cake/Controller/Controller.php b/lib/Cake/Controller/Controller.php
index 8cd10fdf1..78381e90a 100644
--- a/lib/Cake/Controller/Controller.php
+++ b/lib/Cake/Controller/Controller.php
@@ -514,12 +514,12 @@ class Controller extends Object implements CakeEventListener {
!$method->isPublic() ||
!in_array($method->name, $this->methods)
);
- $prefixes = Router::prefixes();
+ $prefixes = array_map('strtolower', Router::prefixes());
if (!$privateAction && !empty($prefixes)) {
if (empty($request->params['prefix']) && strpos($request->params['action'], '_') > 0) {
list($prefix) = explode('_', $request->params['action']);
- $privateAction = in_array($prefix, $prefixes);
+ $privateAction = in_array(strtolower($prefix), $prefixes);
}
}
return $privateAction;
diff --git a/lib/Cake/Error/ErrorHandler.php b/lib/Cake/Error/ErrorHandler.php
index bde45f513..2cce57689 100644
--- a/lib/Cake/Error/ErrorHandler.php
+++ b/lib/Cake/Error/ErrorHandler.php
@@ -156,7 +156,7 @@ class ErrorHandler {
$message .= "\nException Attributes: " . var_export($exception->getAttributes(), true);
}
}
- if (php_sapi_name() !== 'cli') {
+ if (PHP_SAPI !== 'cli') {
$request = Router::getRequest();
if ($request) {
$message .= "\nRequest URL: " . $request->here();
diff --git a/lib/Cake/I18n/I18n.php b/lib/Cake/I18n/I18n.php
index 9f0d06fea..1ce5aae48 100644
--- a/lib/Cake/I18n/I18n.php
+++ b/lib/Cake/I18n/I18n.php
@@ -497,6 +497,9 @@ class I18n {
$msgid = substr($data, $r["offs"], $r["len"]);
unset($msgid_plural);
+ if (strpos($msgid, "\x04") !== false) {
+ list($context, $msgid) = explode("\x04", $msgid);
+ }
if (strpos($msgid, "\000")) {
list($msgid, $msgid_plural) = explode("\000", $msgid);
}
@@ -508,9 +511,10 @@ class I18n {
}
if ($msgid != '') {
- $msgstr = array($context => $msgstr);
+ $translations[$msgid][$context] = $msgstr;
+ } else {
+ $translations[$msgid] = $msgstr;
}
- $translations[$msgid] = $msgstr;
if (isset($msgid_plural)) {
$translations[$msgid_plural] =& $translations[$msgid];
diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php
index 927a6e369..a41e88cef 100644
--- a/lib/Cake/Model/Datasource/DboSource.php
+++ b/lib/Cake/Model/Datasource/DboSource.php
@@ -857,6 +857,12 @@ class DboSource extends DataSource {
* @return bool True if the database is connected, else false
*/
public function isConnected() {
+ try {
+ $connected = $this->_connection->query('SELECT 1');
+ } catch (Exception $e) {
+ $connected = false;
+ }
+ $this->connected = ! empty($connected);
return $this->connected;
}
diff --git a/lib/Cake/Network/Http/HttpSocket.php b/lib/Cake/Network/Http/HttpSocket.php
index 44b514d9f..0fdf4a12d 100644
--- a/lib/Cake/Network/Http/HttpSocket.php
+++ b/lib/Cake/Network/Http/HttpSocket.php
@@ -378,7 +378,7 @@ class HttpSocket extends CakeSocket {
$response = null;
$inHeader = true;
- while ($data = $this->read()) {
+ while (($data = $this->read()) !== false) {
if ($this->_contentResource) {
if ($inHeader) {
$response .= $data;
@@ -719,7 +719,7 @@ class HttpSocket extends CakeSocket {
unset($this->config[$key]);
}
if (version_compare(PHP_VERSION, '5.3.2', '>=')) {
- if (empty($this->config['context']['ssl']['SNI_enabled'])) {
+ if (!isset($this->config['context']['ssl']['SNI_enabled'])) {
$this->config['context']['ssl']['SNI_enabled'] = true;
}
if (version_compare(PHP_VERSION, '5.6.0', '>=')) {
diff --git a/lib/Cake/Test/Case/BasicsTest.php b/lib/Cake/Test/Case/BasicsTest.php
index 25b9e3395..65821693e 100644
--- a/lib/Cake/Test/Case/BasicsTest.php
+++ b/lib/Cake/Test/Case/BasicsTest.php
@@ -952,7 +952,7 @@ EXPECTED;
###########################
EXPECTED;
- if (php_sapi_name() === 'cli') {
+ if (PHP_SAPI === 'cli') {
$expected = sprintf($expectedText, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 18);
} else {
$expected = sprintf($expectedHtml, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 20);
@@ -977,7 +977,7 @@ EXPECTED;
###########################
EXPECTED;
- if (php_sapi_name() === 'cli') {
+ if (PHP_SAPI === 'cli') {
$expected = sprintf($expectedText, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 18);
} else {
$expected = sprintf($expectedHtml, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 19);
@@ -1043,7 +1043,7 @@ EXPECTED;
* @return void
*/
public function testPr() {
- $this->skipIf(php_sapi_name() === 'cli', 'Skipping web test in cli mode');
+ $this->skipIf(PHP_SAPI === 'cli', 'Skipping web test in cli mode');
ob_start();
pr('this is a test');
$result = ob_get_clean();
@@ -1063,7 +1063,7 @@ EXPECTED;
* @return void
*/
public function testPrCli() {
- $this->skipIf(php_sapi_name() != 'cli', 'Skipping cli test in web mode');
+ $this->skipIf(PHP_SAPI !== 'cli', 'Skipping cli test in web mode');
ob_start();
pr('this is a test');
$result = ob_get_clean();
diff --git a/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php b/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php
index 91f019b62..9c56241c2 100644
--- a/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php
+++ b/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php
@@ -34,7 +34,7 @@ class ApcEngineTest extends CakeTestCase {
parent::setUp();
$this->skipIf(!function_exists('apc_store'), 'Apc is not installed or configured properly.');
- if (php_sapi_name() === 'cli') {
+ if (PHP_SAPI === 'cli') {
$this->skipIf(!ini_get('apc.enable_cli'), 'APC is not enabled for the CLI.');
}
diff --git a/lib/Cake/Test/Case/Console/Command/Task/FixtureTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/FixtureTaskTest.php
index dd62bd5f6..a649b7b75 100644
--- a/lib/Cake/Test/Case/Console/Command/Task/FixtureTaskTest.php
+++ b/lib/Cake/Test/Case/Console/Command/Task/FixtureTaskTest.php
@@ -186,6 +186,9 @@ class FixtureTaskTest extends CakeTestCase {
$this->Task->interactive = true;
$this->Task->expects($this->at(0))->method('in')
->will($this->returnValue('WHERE 1=1'));
+ $this->Task->expects($this->at(1))->method('in')
+ ->with($this->anything(), $this->anything(), '3')
+ ->will($this->returnValue('2'));
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
@@ -197,9 +200,8 @@ class FixtureTaskTest extends CakeTestCase {
$this->assertContains('class ArticleFixture extends CakeTestFixture', $result);
$this->assertContains('public $records', $result);
$this->assertContains('public $import', $result);
- $this->assertContains("'title' => 'First Article'", $result, 'Missing import data %s');
- $this->assertContains('Second Article', $result, 'Missing import data %s');
- $this->assertContains('Third Article', $result, 'Missing import data %s');
+ $this->assertContains("'title' => 'First Article'", $result, 'Missing import data');
+ $this->assertContains('Second Article', $result, 'Missing import data');
}
/**
diff --git a/lib/Cake/Test/Case/Controller/Component/EmailComponentTest.php b/lib/Cake/Test/Case/Controller/Component/EmailComponentTest.php
index 7be4282b3..aee72160d 100644
--- a/lib/Cake/Test/Case/Controller/Component/EmailComponentTest.php
+++ b/lib/Cake/Test/Case/Controller/Component/EmailComponentTest.php
@@ -339,6 +339,32 @@ HTMLBLOC;
$this->assertRegExp('/http\:\/\/example\.com/', $result);
}
+/**
+ * test send with null properties
+ *
+ * @return void
+ */
+ public function testSendNullProperties() {
+ $this->Controller->EmailTest->to = 'test@example.com';
+ $this->Controller->EmailTest->from = 'test@example.com';
+ $this->Controller->EmailTest->subject = null;
+ $this->Controller->EmailTest->replyTo = null;
+ $this->Controller->EmailTest->messageId = null;
+ $this->Controller->EmailTest->template = null;
+
+ $this->Controller->EmailTest->delivery = 'DebugComp';
+ $this->assertTrue($this->Controller->EmailTest->send(null));
+ $result = DebugCompTransport::$lastEmail;
+
+ $this->assertRegExp('/To: test@example.com\n/', $result);
+ $this->assertRegExp('/Subject: \n/', $result);
+ $this->assertRegExp('/From: test@example.com\n/', $result);
+ $this->assertRegExp('/Date: ' . preg_quote(static::$sentDate) . '\n/', $result);
+ $this->assertRegExp('/X-Mailer: CakePHP Email Component\n/', $result);
+ $this->assertRegExp('/Content-Type: text\/plain; charset=UTF-8\n/', $result);
+ $this->assertRegExp('/Content-Transfer-Encoding: 8bitMessage:\n/', $result);
+ }
+
/**
* testSendDebug method
*
diff --git a/lib/Cake/Test/Case/Controller/ControllerTest.php b/lib/Cake/Test/Case/Controller/ControllerTest.php
index 534825e37..f319bd167 100644
--- a/lib/Cake/Test/Case/Controller/ControllerTest.php
+++ b/lib/Cake/Test/Case/Controller/ControllerTest.php
@@ -1447,6 +1447,25 @@ class ControllerTest extends CakeTestCase {
$Controller->invokeAction($url);
}
+/**
+ * test invoking controller methods.
+ *
+ * @expectedException PrivateActionException
+ * @expectedExceptionMessage Private Action TestController::Admin_add() is not directly accessible.
+ * @return void
+ */
+ public function testInvokeActionPrefixProtectionCasing() {
+ Router::reload();
+ Router::connect('/admin/:controller/:action/*', array('prefix' => 'admin'));
+
+ $url = new CakeRequest('test/Admin_add/');
+ $url->addParams(array('controller' => 'test_controller', 'action' => 'Admin_add'));
+ $response = $this->getMock('CakeResponse');
+
+ $Controller = new TestController($url, $response);
+ $Controller->invokeAction($url);
+ }
+
/**
* test invoking controller methods.
*
diff --git a/lib/Cake/Test/Case/I18n/I18nTest.php b/lib/Cake/Test/Case/I18n/I18nTest.php
index 79657c461..faac0e069 100644
--- a/lib/Cake/Test/Case/I18n/I18nTest.php
+++ b/lib/Cake/Test/Case/I18n/I18nTest.php
@@ -2040,6 +2040,22 @@ class I18nTest extends CakeTestCase {
$this->assertSame("saldo", __x('money', 'balance'));
}
+/**
+ * Test basic context support using mo files.
+ *
+ * @return void
+ */
+ public function testContextMoFile() {
+ Configure::write('Config.language', 'nld_mo');
+
+ $this->assertSame("brief", __x('mail', 'letter'));
+ $this->assertSame("letter", __x('character', 'letter'));
+ $this->assertSame("bal", __x('spherical object', 'ball'));
+ $this->assertSame("danspartij", __x('social gathering', 'ball'));
+ $this->assertSame("balans", __('balance'));
+ $this->assertSame("saldo", __x('money', 'balance'));
+ }
+
/**
* Singular method
*
diff --git a/lib/Cake/Test/Case/Network/CakeResponseTest.php b/lib/Cake/Test/Case/Network/CakeResponseTest.php
index 82a2f0419..41e2eba07 100644
--- a/lib/Cake/Test/Case/Network/CakeResponseTest.php
+++ b/lib/Cake/Test/Case/Network/CakeResponseTest.php
@@ -373,7 +373,7 @@ class CakeResponseTest extends CakeTestCase {
* @return void
*/
public function testCompress() {
- if (php_sapi_name() !== 'cli') {
+ if (PHP_SAPI !== 'cli') {
$this->markTestSkipped('The response compression can only be tested in cli.');
}
@@ -491,7 +491,7 @@ class CakeResponseTest extends CakeTestCase {
if (!extension_loaded("zlib")) {
$this->markTestSkipped('Skipping further tests for outputCompressed as zlib extension is not loaded');
}
- if (php_sapi_name() !== 'cli') {
+ if (PHP_SAPI !== 'cli') {
$this->markTestSkipped('Testing outputCompressed method with compression enabled done only in cli');
}
diff --git a/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php b/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php
index de04f18ed..6ff788348 100644
--- a/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php
+++ b/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php
@@ -307,6 +307,10 @@ class HttpSocketTest extends CakeTestCase {
* @return void
*/
public function testRequest() {
+ $this->Socket->expects($this->any())
+ ->method('read')
+ ->will($this->returnValue(false));
+
$this->Socket->reset();
$response = $this->Socket->request(true);
@@ -589,6 +593,10 @@ class HttpSocketTest extends CakeTestCase {
* @return void
*/
public function testGetWithSchemeAndPort() {
+ $this->Socket->expects($this->any())
+ ->method('read')
+ ->will($this->returnValue(false));
+
$this->Socket->reset();
$request = array(
'uri' => array(
@@ -609,6 +617,10 @@ class HttpSocketTest extends CakeTestCase {
* @return void
*/
public function testRequestWithStringQuery() {
+ $this->Socket->expects($this->any())
+ ->method('read')
+ ->will($this->returnValue(false));
+
$this->Socket->reset();
$request = array(
'uri' => array(
@@ -642,14 +654,18 @@ class HttpSocketTest extends CakeTestCase {
*/
public function testRequest2() {
$this->Socket->reset();
+
$request = array('uri' => 'htpp://www.cakephp.org/');
$number = mt_rand(0, 9999999);
$this->Socket->expects($this->any())->method('connect')->will($this->returnValue(true));
$serverResponse = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\nHello, your lucky number is " . $number . "
";
$this->Socket->expects($this->at(0))->method('write')
->with("GET / HTTP/1.1\r\nHost: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\n\r\n");
- $this->Socket->expects($this->at(0))->method('read')->will($this->returnValue(false));
- $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse));
+
+ $this->Socket->expects($this->any())
+ ->method('read')
+ ->will($this->onConsecutiveCalls($serverResponse, false));
+
$response = (string)$this->Socket->request($request);
$this->assertEquals($response, "Hello, your lucky number is " . $number . "
");
}
@@ -662,7 +678,11 @@ class HttpSocketTest extends CakeTestCase {
public function testRequest3() {
$request = array('uri' => 'htpp://www.cakephp.org/');
$serverResponse = "HTTP/1.x 200 OK\r\nSet-Cookie: foo=bar\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\nThis is a cookie test!
";
- $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse));
+
+ $this->Socket->expects($this->any())
+ ->method('read')
+ ->will($this->onConsecutiveCalls($serverResponse, false));
+
$this->Socket->connected = true;
$this->Socket->request($request);
$result = $this->Socket->response['cookies'];
@@ -711,9 +731,10 @@ class HttpSocketTest extends CakeTestCase {
*/
public function testRequestWithResource() {
$serverResponse = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\nThis is a test!
";
- $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse));
- $this->Socket->expects($this->at(2))->method('read')->will($this->returnValue(false));
- $this->Socket->expects($this->at(4))->method('read')->will($this->returnValue($serverResponse));
+
+ $this->Socket->expects($this->any())
+ ->method('read')
+ ->will($this->onConsecutiveCalls($serverResponse, false, $serverResponse, false));
$this->Socket->connected = true;
$f = fopen(TMP . 'download.txt', 'w');
@@ -744,8 +765,10 @@ class HttpSocketTest extends CakeTestCase {
$this->Socket->config['request']['cookies'] = array();
$serverResponse = "HTTP/1.x 200 OK\r\nSet-Cookie: foo=bar\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\nThis is a test!
";
+
$this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse));
$this->Socket->expects($this->at(2))->method('read')->will($this->returnValue(false));
+
$expected = array('www.cakephp.org' => array('foo' => array('value' => 'bar')));
$this->Socket->request('http://www.cakephp.org/');
$this->assertEquals($expected, $this->Socket->config['request']['cookies']);
@@ -781,8 +804,9 @@ class HttpSocketTest extends CakeTestCase {
public function testRequestCustomResponse() {
$this->Socket->connected = true;
$serverResponse = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\nThis is a test!
";
- $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse));
- $this->Socket->expects($this->at(2))->method('read')->will($this->returnValue(false));
+ $this->Socket->expects($this->any())
+ ->method('read')
+ ->will($this->onConsecutiveCalls($serverResponse, false));
$this->Socket->responseClass = 'CustomResponse';
$response = $this->Socket->request('http://www.cakephp.org/');
@@ -817,6 +841,8 @@ class HttpSocketTest extends CakeTestCase {
$this->Socket->expects($this->at(4))
->method('read')
->will($this->returnValue($serverResponse2));
+ $this->Socket->expects($this->any())
+ ->method('read')->will($this->returnValue(false));
$response = $this->Socket->request($request);
$this->assertEquals('You have been redirected
', $response->body());
@@ -834,8 +860,10 @@ class HttpSocketTest extends CakeTestCase {
);
$serverResponse1 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://localhost/anotheruri\r\n\r\n";
$serverResponse2 = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\nYou have been redirected
";
- $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse1));
- $this->Socket->expects($this->at(4))->method('read')->will($this->returnValue($serverResponse2));
+
+ $this->Socket->expects($this->any())
+ ->method('read')
+ ->will($this->onConsecutiveCalls($serverResponse1, false, $serverResponse2, false));
$response = $this->Socket->request($request);
$this->assertEquals('You have been redirected
', $response->body());
@@ -853,8 +881,10 @@ class HttpSocketTest extends CakeTestCase {
);
$serverResponse1 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://localhost/anotheruri\r\n\r\n";
$serverResponse2 = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\nYou have been redirected
";
- $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse1));
- $this->Socket->expects($this->at(4))->method('read')->will($this->returnValue($serverResponse2));
+
+ $this->Socket->expects($this->any())
+ ->method('read')
+ ->will($this->onConsecutiveCalls($serverResponse1, false, $serverResponse2, false));
$this->Socket->request($request);
$this->assertEquals(1, $this->Socket->request['redirect']);
@@ -872,8 +902,10 @@ class HttpSocketTest extends CakeTestCase {
);
$serverResponse1 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://localhost/oneruri\r\n\r\n";
$serverResponse2 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://localhost/anotheruri\r\n\r\n";
- $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse1));
- $this->Socket->expects($this->at(4))->method('read')->will($this->returnValue($serverResponse2));
+
+ $this->Socket->expects($this->any())
+ ->method('read')
+ ->will($this->onConsecutiveCalls($serverResponse1, false, $serverResponse2, false));
$response = $this->Socket->request($request);
$this->assertEquals(0, $this->Socket->request['redirect']);
@@ -1113,6 +1145,9 @@ class HttpSocketTest extends CakeTestCase {
* @return void
*/
public function testAuth() {
+ $this->Socket->expects($this->any())
+ ->method('read')->will($this->returnValue(false));
+
$this->Socket->get('http://mark:secret@example.com/test');
$this->assertTrue(strpos($this->Socket->request['header'], 'Authorization: Basic bWFyazpzZWNyZXQ=') !== false);
@@ -1154,6 +1189,9 @@ class HttpSocketTest extends CakeTestCase {
* @return void
*/
public function testConsecutiveGetResetsAuthCredentials() {
+ $this->Socket->expects($this->any())
+ ->method('read')->will($this->returnValue(false));
+
$this->Socket->get('http://mark:secret@example.com/test');
$this->assertEquals('mark', $this->Socket->request['uri']['user']);
$this->assertEquals('secret', $this->Socket->request['uri']['pass']);
@@ -1813,6 +1851,9 @@ class HttpSocketTest extends CakeTestCase {
* @return void
*/
public function testConfigContext() {
+ $this->Socket->expects($this->any())
+ ->method('read')->will($this->returnValue(false));
+
$this->Socket->reset();
$this->Socket->request('http://example.com');
$this->assertTrue($this->Socket->config['context']['ssl']['verify_peer']);
@@ -1869,8 +1910,10 @@ class HttpSocketTest extends CakeTestCase {
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\nThis is a test!
";
- $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse));
- $this->Socket->expects($this->at(2))->method('read')->will($this->returnValue(false));
+
+ $this->Socket->expects($this->any())
+ ->method('read')
+ ->will($this->onConsecutiveCalls($serverResponse, false));
$response = $this->Socket->request('http://www.cakephp.org/');
$this->assertInstanceOf('HttpSocketResponse', $response);
diff --git a/lib/Cake/Test/Case/Utility/DebuggerTest.php b/lib/Cake/Test/Case/Utility/DebuggerTest.php
index e967e7776..4179a7636 100644
--- a/lib/Cake/Test/Case/Utility/DebuggerTest.php
+++ b/lib/Cake/Test/Case/Utility/DebuggerTest.php
@@ -516,8 +516,8 @@ TEXT;
Debugger::dump($var);
$result = ob_get_clean();
- $open = php_sapi_name() === 'cli' ? "\n" : '
';
- $close = php_sapi_name() === 'cli' ? "\n" : '
';
+ $open = PHP_SAPI === 'cli' ? "\n" : '';
+ $close = PHP_SAPI === 'cli' ? "\n" : '
';
$expected = << array(
@@ -540,8 +540,8 @@ TEXT;
Debugger::dump($var, 1);
$result = ob_get_clean();
- $open = php_sapi_name() === 'cli' ? "\n" : '';
- $close = php_sapi_name() === 'cli' ? "\n" : '
';
+ $open = PHP_SAPI === 'cli' ? "\n" : '';
+ $close = PHP_SAPI === 'cli' ? "\n" : '
';
$expected = << array(
diff --git a/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php b/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php
index c92c4923b..4d768d0d8 100644
--- a/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php
+++ b/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php
@@ -583,4 +583,33 @@ class ObjectCollectionTest extends CakeTestCase {
$this->assertTrue($this->Objects->trigger($event));
}
+/**
+ * test that the various methods ignore plugin prefixes
+ *
+ * plugin prefixes should be removed consistently as load() will
+ * remove them. Furthermore the __get() method does not support
+ * names with '.' in them.
+ *
+ * @return void
+ */
+ public function testPluginPrefixes() {
+ $this->Objects->load('TestPlugin.First');
+ $this->assertTrue($this->Objects->loaded('First'));
+ $this->assertTrue($this->Objects->loaded('TestPlugin.First'));
+
+ $this->assertTrue($this->Objects->enabled('First'));
+ $this->assertTrue($this->Objects->enabled('TestPlugin.First'));
+
+ $this->assertNull($this->Objects->disable('TestPlugin.First'));
+ $this->assertFalse($this->Objects->enabled('First'));
+ $this->assertFalse($this->Objects->enabled('TestPlugin.First'));
+
+ $this->assertNull($this->Objects->enable('TestPlugin.First'));
+ $this->assertTrue($this->Objects->enabled('First'));
+ $this->assertTrue($this->Objects->enabled('TestPlugin.First'));
+ $this->Objects->setPriority('TestPlugin.First', 1000);
+
+ $result = $this->Objects->prioritize();
+ $this->assertEquals(1000, $result['First'][0]);
+ }
}
diff --git a/lib/Cake/Test/Case/Utility/ValidationTest.php b/lib/Cake/Test/Case/Utility/ValidationTest.php
index a8f0e957f..f501e4f6b 100644
--- a/lib/Cake/Test/Case/Utility/ValidationTest.php
+++ b/lib/Cake/Test/Case/Utility/ValidationTest.php
@@ -930,6 +930,25 @@ class ValidationTest extends CakeTestCase {
$this->assertFalse(Validation::comparison(7, '==', 6));
$this->assertFalse(Validation::comparison(7, 'not equal', 7));
$this->assertFalse(Validation::comparison(7, '!=', 7));
+
+ $this->assertTrue(Validation::comparison('6.5', '!=', 6));
+ $this->assertTrue(Validation::comparison('6.5', '<', 7));
+ }
+
+/**
+ * Test comparison casting values before comparisons.
+ *
+ * @return void
+ */
+ public function testComparisonTypeChecks() {
+ $this->assertFalse(Validation::comparison('\x028', '>=', 1), 'hexish encoding fails');
+ $this->assertFalse(Validation::comparison('0b010', '>=', 1), 'binary string data fails');
+ $this->assertFalse(Validation::comparison('0x01', '>=', 1), 'hex string data fails');
+ $this->assertFalse(Validation::comparison('0x1', '>=', 1), 'hex string data fails');
+
+ $this->assertFalse(Validation::comparison('\x028', '>=', 1.5), 'hexish encoding fails');
+ $this->assertFalse(Validation::comparison('0b010', '>=', 1.5), 'binary string data fails');
+ $this->assertFalse(Validation::comparison('0x02', '>=', 1.5), 'hex string data fails');
}
/**
@@ -2004,6 +2023,22 @@ class ValidationTest extends CakeTestCase {
$this->assertFalse(Validation::range('word'));
}
+/**
+ * Test range type checks
+ *
+ * @return void
+ */
+ public function testRangeTypeChecks() {
+ $this->assertFalse(Validation::range('\x028', 1, 5), 'hexish encoding fails');
+ $this->assertFalse(Validation::range('0b010', 1, 5), 'binary string data fails');
+ $this->assertFalse(Validation::range('0x01', 1, 5), 'hex string data fails');
+ $this->assertFalse(Validation::range('0x1', 1, 5), 'hex string data fails');
+
+ $this->assertFalse(Validation::range('\x028', 1, 5), 'hexish encoding fails');
+ $this->assertFalse(Validation::range('0b010', 1, 5), 'binary string data fails');
+ $this->assertFalse(Validation::range('0x02', 1, 5), 'hex string data fails');
+ }
+
/**
* testExtension method
*
diff --git a/lib/Cake/Test/test_app/Locale/nld_mo/LC_MESSAGES/default.mo b/lib/Cake/Test/test_app/Locale/nld_mo/LC_MESSAGES/default.mo
new file mode 100644
index 000000000..bb89fa6e9
Binary files /dev/null and b/lib/Cake/Test/test_app/Locale/nld_mo/LC_MESSAGES/default.mo differ
diff --git a/lib/Cake/Utility/ObjectCollection.php b/lib/Cake/Utility/ObjectCollection.php
index 4bbb1a3ea..49e4ae9f8 100644
--- a/lib/Cake/Utility/ObjectCollection.php
+++ b/lib/Cake/Utility/ObjectCollection.php
@@ -176,6 +176,7 @@ abstract class ObjectCollection {
public function enable($name, $prioritize = true) {
$enabled = false;
foreach ((array)$name as $object) {
+ list(, $object) = pluginSplit($object);
if (isset($this->_loaded[$object]) && !isset($this->_enabled[$object])) {
$priority = $this->defaultPriority;
if (isset($this->_loaded[$object]->settings['priority'])) {
@@ -219,6 +220,7 @@ abstract class ObjectCollection {
$name = array($name => $priority);
}
foreach ($name as $object => $objectPriority) {
+ list(, $object) = pluginSplit($object);
if (isset($this->_loaded[$object])) {
if ($objectPriority === null) {
$objectPriority = $this->defaultPriority;
@@ -241,6 +243,7 @@ abstract class ObjectCollection {
*/
public function disable($name) {
foreach ((array)$name as $object) {
+ list(, $object) = pluginSplit($object);
unset($this->_enabled[$object]);
}
}
@@ -255,6 +258,7 @@ abstract class ObjectCollection {
*/
public function enabled($name = null) {
if (!empty($name)) {
+ list(, $name) = pluginSplit($name);
return isset($this->_enabled[$name]);
}
return array_keys($this->_enabled);
@@ -283,6 +287,7 @@ abstract class ObjectCollection {
*/
public function loaded($name = null) {
if (!empty($name)) {
+ list(, $name) = pluginSplit($name);
return isset($this->_loaded[$name]);
}
return array_keys($this->_loaded);
diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php
index 6cdd745b0..40449ab0d 100644
--- a/lib/Cake/Utility/Validation.php
+++ b/lib/Cake/Utility/Validation.php
@@ -242,6 +242,10 @@ class Validation {
if (is_array($check1)) {
extract($check1, EXTR_OVERWRITE);
}
+
+ if ((float)$check1 != $check1) {
+ return false;
+ }
$operator = str_replace(array(' ', "\t", "\n", "\r", "\0", "\x0B"), '', strtolower($operator));
switch ($operator) {
@@ -757,6 +761,9 @@ class Validation {
if (!is_numeric($check)) {
return false;
}
+ if ((float)$check != $check) {
+ return false;
+ }
if (isset($lower) && isset($upper)) {
return ($check > $lower && $check < $upper);
}
diff --git a/lib/Cake/basics.php b/lib/Cake/basics.php
index 3b8070942..51afffa18 100644
--- a/lib/Cake/basics.php
+++ b/lib/Cake/basics.php
@@ -100,7 +100,7 @@ HTML;
TEXT;
$template = $html;
- if (php_sapi_name() === 'cli' || $showHtml === false) {
+ if (PHP_SAPI === 'cli' || $showHtml === false) {
$template = $text;
if ($showFrom) {
$lineInfo = sprintf('%s (line %s)', $file, $line);
@@ -275,7 +275,7 @@ if (!function_exists('pr')) {
*/
function pr($var) {
if (Configure::read('debug') > 0) {
- $template = php_sapi_name() !== 'cli' ? '%s
' : "\n%s\n";
+ $template = PHP_SAPI !== 'cli' ? '%s
' : "\n%s\n";
printf($template, print_r($var, true));
}
}
diff --git a/lib/Cake/bootstrap.php b/lib/Cake/bootstrap.php
index 4ad77a21b..b17c9f68f 100644
--- a/lib/Cake/bootstrap.php
+++ b/lib/Cake/bootstrap.php
@@ -172,17 +172,6 @@ Configure::write('App.imageBaseUrl', IMAGES_URL);
Configure::write('App.cssBaseUrl', CSS_URL);
Configure::write('App.jsBaseUrl', JS_URL);
-Configure::bootstrap(isset($boot) ? $boot : true);
-
-if (function_exists('mb_internal_encoding')) {
- $encoding = Configure::read('App.encoding');
- if (!empty($encoding)) {
- mb_internal_encoding($encoding);
- }
- if (!empty($encoding) && function_exists('mb_regex_encoding')) {
- mb_regex_encoding($encoding);
- }
-}
if (!function_exists('mb_stripos')) {
@@ -438,3 +427,15 @@ if (!function_exists('mb_encode_mimeheader')) {
}
}
+
+Configure::bootstrap(isset($boot) ? $boot : true);
+
+if (function_exists('mb_internal_encoding')) {
+ $encoding = Configure::read('App.encoding');
+ if (!empty($encoding)) {
+ mb_internal_encoding($encoding);
+ }
+ if (!empty($encoding) && function_exists('mb_regex_encoding')) {
+ mb_regex_encoding($encoding);
+ }
+}