Skip to content

Commit

Permalink
Merge branch 'master' into 2.6
Browse files Browse the repository at this point in the history
Conflicts:
	lib/Cake/VERSION.txt
  • Loading branch information
ADmad committed Jul 27, 2014
2 parents 7a14ed7 + d6733e3 commit 9e21d04
Show file tree
Hide file tree
Showing 12 changed files with 170 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -12,6 +12,7 @@

# IDE and editor specific files #
#################################
/nbproject
.idea

# OS generated files #
Expand Down
6 changes: 3 additions & 3 deletions app/Config/Schema/db_acl.sql
Expand Up @@ -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`);
4 changes: 2 additions & 2 deletions lib/Cake/Console/Command/Task/ProjectTask.php
Expand Up @@ -237,8 +237,8 @@ public function consolePath($path) {
$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;
Expand Down
13 changes: 12 additions & 1 deletion lib/Cake/Console/Templates/skel/Config/Schema/db_acl.sql
Expand Up @@ -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`);
3 changes: 2 additions & 1 deletion lib/Cake/Controller/Component/AuthComponent.php
Expand Up @@ -367,7 +367,8 @@ protected function _unauthenticated(Controller $controller) {
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;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Network/CakeRequest.php
Expand Up @@ -207,7 +207,7 @@ protected function _processGet() {
$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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Network/Email/CakeEmail.php
Expand Up @@ -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.
Expand Down
20 changes: 12 additions & 8 deletions lib/Cake/Network/Email/SmtpTransport.php
Expand Up @@ -191,18 +191,22 @@ protected function _connect() {
*/
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.'));
}
}
}
Expand Down
32 changes: 32 additions & 0 deletions lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php
Expand Up @@ -1155,6 +1155,38 @@ public function testAjaxLogin() {
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
*
Expand Down
14 changes: 14 additions & 0 deletions lib/Cake/Test/Case/Network/CakeRequestTest.php
Expand Up @@ -2218,6 +2218,20 @@ public function testHere() {
$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.
*
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Test/Case/Network/Email/CakeEmailTest.php
Expand Up @@ -251,15 +251,15 @@ public function testTo() {
$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'
);
$this->CakeEmail->to($list);
$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'
);
Expand All @@ -271,7 +271,7 @@ public function testTo() {
$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',
Expand Down
87 changes: 87 additions & 0 deletions lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php
Expand Up @@ -130,6 +130,7 @@ public function testConnectEhloTls() {
* 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() {
Expand All @@ -150,6 +151,7 @@ public function testConnectEhloTlsOnNonTlsServer() {
* testConnectEhloNoTlsOnRequiredTlsServer method
*
* @expectedException SocketException
* @expectedExceptionMessage SMTP authentication method not allowed, check if SMTP server requires TLS.
* @return void
*/
public function testConnectEhloNoTlsOnRequiredTlsServer() {
Expand Down Expand Up @@ -189,6 +191,7 @@ public function testConnectHelo() {
* testConnectFail method
*
* @expectedException SocketException
* @expectedExceptionMessage SMTP server did not accept the connection.
* @return void
*/
public function testConnectFail() {
Expand Down Expand Up @@ -223,6 +226,90 @@ public function testAuth() {
$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
*
Expand Down

0 comments on commit 9e21d04

Please sign in to comment.