Merge branch 'master' into 2.6

Conflicts:
	lib/Cake/VERSION.txt
This commit is contained in:
ADmad 2014-07-27 12:29:39 +05:30
commit 9e21d048ce
12 changed files with 170 additions and 20 deletions

1
.gitignore vendored
View file

@ -12,6 +12,7 @@
# IDE and editor specific files #
#################################
/nbproject
.idea
# OS generated files #

View file

@ -41,12 +41,12 @@ CREATE TABLE aros (
);
/* this indexes will improve acl perfomance */
CREATE INDEX idx_acos_lft_rght ON `acos` (`lft`, `rhgt`);
CREATE INDEX idx_acos_lft_rght ON `acos` (`lft`, `rght`);
CREATE INDEX idx_acos_alias ON `acos` (`alias`);
CREATE INDEX idx_aros_lft_rght ON `aros` (`lft`, `rhgt`);
CREATE INDEX idx_aros_lft_rght ON `aros` (`lft`, `rght`);
CREATE INDEX idx_aros_alias ON `aros` (`alias`);
CREATE INDEX idx_aco_id ON `aros_acos` (`aco_id`);
CREATE INDEX idx_aco_id ON `aros_acos` (`aco_id`);

View file

@ -237,8 +237,8 @@ class ProjectTask extends AppShell {
$File = new File($path . 'Console' . DS . 'cake.php');
$contents = $File->read();
if (preg_match('/(__CAKE_PATH__)/', $contents, $match)) {
$root = strpos(CAKE_CORE_INCLUDE_PATH, '/') === 0 ? " \$ds . '" : "'";
$replacement = $root . str_replace(DS, "' . \$ds . '", trim(CAKE_CORE_INCLUDE_PATH, DS)) . "'";
$root = strpos(CAKE_CORE_INCLUDE_PATH, '/') === 0 ? " DS . '" : "'";
$replacement = $root . str_replace(DS, "' . DS . '", trim(CAKE_CORE_INCLUDE_PATH, DS)) . "'";
$result = str_replace($match[0], $replacement, $contents);
if ($File->write($result)) {
return true;

View file

@ -38,4 +38,15 @@ CREATE TABLE aros (
lft INTEGER(10) DEFAULT NULL,
rght INTEGER(10) DEFAULT NULL,
PRIMARY KEY (id)
);
);
/* this indexes will improve acl perfomance */
CREATE INDEX idx_acos_lft_rght ON `acos` (`lft`, `rght`);
CREATE INDEX idx_acos_alias ON `acos` (`alias`);
CREATE INDEX idx_aros_lft_rght ON `aros` (`lft`, `rght`);
CREATE INDEX idx_aros_alias ON `aros` (`alias`);
CREATE INDEX idx_aco_id ON `aros_acos` (`aco_id`);

View file

@ -367,7 +367,8 @@ class AuthComponent extends Component {
if (!empty($this->ajaxLogin)) {
$controller->response->statusCode(403);
$controller->viewPath = 'Elements';
echo $controller->render($this->ajaxLogin, $this->RequestHandler->ajaxLayout);
$response = $controller->render($this->ajaxLogin, $this->RequestHandler->ajaxLayout);
$response->send();
$this->_stop();
return false;
}

View file

@ -207,7 +207,7 @@ class CakeRequest implements ArrayAccess {
$query = $_GET;
}
$unsetUrl = '/' . str_replace('.', '_', urldecode($this->url));
$unsetUrl = '/' . str_replace(array('.', ' '), '_', urldecode($this->url));
unset($query[$unsetUrl]);
unset($query[$this->base . $unsetUrl]);
if (strpos($this->url, '?') !== false) {

View file

@ -320,7 +320,7 @@ class CakeEmail {
*
* @var string
*/
protected $_emailPattern = '/^((?:[\p{L}0-9!#$%&\'*+\/=?^_`{|}~-]+)*@[\p{L}0-9-.]+)$/ui';
protected $_emailPattern = '/^((?:[\p{L}0-9.!#$%&\'*+\/=?^_`{|}~-]+)*@[\p{L}0-9-.]+)$/ui';
/**
* The class name used for email configuration.

View file

@ -191,18 +191,22 @@ class SmtpTransport extends AbstractTransport {
*/
protected function _auth() {
if (isset($this->_config['username']) && isset($this->_config['password'])) {
$authRequired = $this->_smtpSend('AUTH LOGIN', '334|503');
if ($authRequired == '334') {
if (!$this->_smtpSend(base64_encode($this->_config['username']), '334')) {
$replyCode = $this->_smtpSend('AUTH LOGIN', '334|500|502|504');
if ($replyCode == '334') {
try {
$this->_smtpSend(base64_encode($this->_config['username']), '334');
} catch (SocketException $e) {
throw new SocketException(__d('cake_dev', 'SMTP server did not accept the username.'));
}
if (!$this->_smtpSend(base64_encode($this->_config['password']), '235')) {
try {
$this->_smtpSend(base64_encode($this->_config['password']), '235');
} catch (SocketException $e) {
throw new SocketException(__d('cake_dev', 'SMTP server did not accept the password.'));
}
} elseif ($authRequired == '504') {
throw new SocketException(__d('cake_dev', 'SMTP authentication method not allowed, check if SMTP server requires TLS'));
} elseif ($authRequired != '503') {
throw new SocketException(__d('cake_dev', 'SMTP does not require authentication.'));
} elseif ($replyCode == '504') {
throw new SocketException(__d('cake_dev', 'SMTP authentication method not allowed, check if SMTP server requires TLS.'));
} else {
throw new SocketException(__d('cake_dev', 'AUTH command not recognized or not implemented, SMTP server may not require authentication.'));
}
}
}

View file

@ -1155,6 +1155,38 @@ class AuthComponentTest extends CakeTestCase {
unset($_SERVER['HTTP_X_REQUESTED_WITH']);
}
/**
* testAjaxLoginResponseCode
*
* @return void
*/
public function testAjaxLoginResponseCode() {
App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
$url = '/ajax_auth/add';
$this->Auth->request->addParams(Router::parse($url));
$this->Auth->request->query['url'] = ltrim($url, '/');
$this->Auth->request->base = '';
$this->Auth->ajaxLogin = 'test_element';
Router::setRequestInfo($this->Auth->request);
$this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader'));
$this->Controller->response->expects($this->at(0))
->method('_sendHeader')
->with('HTTP/1.1 403 Forbidden', null);
$this->Auth->initialize($this->Controller);
$result = $this->Auth->startup($this->Controller);
$this->assertFalse($result);
$this->assertEquals('this is the test element', $this->Controller->response->body());
unset($_SERVER['HTTP_X_REQUESTED_WITH']);
}
/**
* testLoginActionRedirect method
*

View file

@ -2218,6 +2218,20 @@ class CakeRequestTest extends CakeTestCase {
$this->assertEquals('/posts/base_path/1/name:value?test=value', $result);
}
/**
* Test the here() with space in URL
*
* @return void
*/
public function testHereWithSpaceInUrl() {
Configure::write('App.base', '');
$_GET = array('/admin/settings/settings/prefix/Access_Control' => '');
$request = new CakeRequest('/admin/settings/settings/prefix/Access%20Control');
$result = $request->here();
$this->assertEquals('/admin/settings/settings/prefix/Access%20Control', $result);
}
/**
* Test the input() method.
*

View file

@ -251,7 +251,7 @@ class CakeEmailTest extends CakeTestCase {
$list = array(
'root@localhost' => 'root',
'bjørn@hammeröath.com' => 'Bjorn',
'cake@cakephp.org' => 'Cake PHP',
'cake.php@cakephp.org' => 'Cake PHP',
'cake-php@googlegroups.com' => 'Cake Groups',
'root@cakephp.org'
);
@ -259,7 +259,7 @@ class CakeEmailTest extends CakeTestCase {
$expected = array(
'root@localhost' => 'root',
'bjørn@hammeröath.com' => 'Bjorn',
'cake@cakephp.org' => 'Cake PHP',
'cake.php@cakephp.org' => 'Cake PHP',
'cake-php@googlegroups.com' => 'Cake Groups',
'root@cakephp.org' => 'root@cakephp.org'
);
@ -271,7 +271,7 @@ class CakeEmailTest extends CakeTestCase {
$expected = array(
'root@localhost' => 'root',
'bjørn@hammeröath.com' => 'Bjorn',
'cake@cakephp.org' => 'Cake PHP',
'cake.php@cakephp.org' => 'Cake PHP',
'cake-php@googlegroups.com' => 'Cake Groups',
'root@cakephp.org' => 'root@cakephp.org',
'jrbasso@cakephp.org' => 'jrbasso@cakephp.org',

View file

@ -130,6 +130,7 @@ class SmtpTransportTest extends CakeTestCase {
* testConnectEhloTlsOnNonTlsServer method
*
* @expectedException SocketException
* @expectedExceptionMessage SMTP server did not accept the connection or trying to connect to non TLS SMTP server using TLS.
* @return void
*/
public function testConnectEhloTlsOnNonTlsServer() {
@ -150,6 +151,7 @@ class SmtpTransportTest extends CakeTestCase {
* testConnectEhloNoTlsOnRequiredTlsServer method
*
* @expectedException SocketException
* @expectedExceptionMessage SMTP authentication method not allowed, check if SMTP server requires TLS.
* @return void
*/
public function testConnectEhloNoTlsOnRequiredTlsServer() {
@ -189,6 +191,7 @@ class SmtpTransportTest extends CakeTestCase {
* testConnectFail method
*
* @expectedException SocketException
* @expectedExceptionMessage SMTP server did not accept the connection.
* @return void
*/
public function testConnectFail() {
@ -223,6 +226,90 @@ class SmtpTransportTest extends CakeTestCase {
$this->SmtpTransport->auth();
}
/**
* testAuthNotRecognized method
*
* @expectedException SocketException
* @expectedExceptionMessage AUTH command not recognized or not implemented, SMTP server may not require authentication.
* @return void
*/
public function testAuthNotRecognized() {
$this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n");
$this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false));
$this->socket->expects($this->at(2))->method('read')->will($this->returnValue("500 5.3.3 Unrecognized command\r\n"));
$this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story'));
$this->SmtpTransport->auth();
}
/**
* testAuthNotImplemented method
*
* @expectedException SocketException
* @expectedExceptionMessage AUTH command not recognized or not implemented, SMTP server may not require authentication.
* @return void
*/
public function testAuthNotImplemented() {
$this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n");
$this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false));
$this->socket->expects($this->at(2))->method('read')->will($this->returnValue("502 5.3.3 Command not implemented\r\n"));
$this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story'));
$this->SmtpTransport->auth();
}
/**
* testAuthBadSequence method
*
* @expectedException SocketException
* @expectedExceptionMessage SMTP Error: 503 5.5.1 Already authenticated
* @return void
*/
public function testAuthBadSequence() {
$this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n");
$this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false));
$this->socket->expects($this->at(2))->method('read')->will($this->returnValue("503 5.5.1 Already authenticated\r\n"));
$this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story'));
$this->SmtpTransport->auth();
}
/**
* testAuthBadUsername method
*
* @expectedException SocketException
* @expectedExceptionMessage SMTP server did not accept the username.
* @return void
*/
public function testAuthBadUsername() {
$this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n");
$this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false));
$this->socket->expects($this->at(2))->method('read')->will($this->returnValue("334 Login\r\n"));
$this->socket->expects($this->at(3))->method('write')->with("bWFyaw==\r\n");
$this->socket->expects($this->at(4))->method('read')->will($this->returnValue(false));
$this->socket->expects($this->at(5))->method('read')->will($this->returnValue("535 5.7.8 Authentication failed\r\n"));
$this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story'));
$this->SmtpTransport->auth();
}
/**
* testAuthBadPassword method
*
* @expectedException SocketException
* @expectedExceptionMessage SMTP server did not accept the password.
* @return void
*/
public function testAuthBadPassword() {
$this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n");
$this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false));
$this->socket->expects($this->at(2))->method('read')->will($this->returnValue("334 Login\r\n"));
$this->socket->expects($this->at(3))->method('write')->with("bWFyaw==\r\n");
$this->socket->expects($this->at(4))->method('read')->will($this->returnValue(false));
$this->socket->expects($this->at(5))->method('read')->will($this->returnValue("334 Pass\r\n"));
$this->socket->expects($this->at(6))->method('write')->with("c3Rvcnk=\r\n");
$this->socket->expects($this->at(7))->method('read')->will($this->returnValue(false));
$this->socket->expects($this->at(8))->method('read')->will($this->returnValue("535 5.7.8 Authentication failed\r\n"));
$this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story'));
$this->SmtpTransport->auth();
}
/**
* testAuthNoAuth method
*