diff --git a/lib/Cake/Controller/Component/PaginatorComponent.php b/lib/Cake/Controller/Component/PaginatorComponent.php
index abda854ec..32107f413 100644
--- a/lib/Cake/Controller/Component/PaginatorComponent.php
+++ b/lib/Cake/Controller/Component/PaginatorComponent.php
@@ -212,9 +212,6 @@ class PaginatorComponent extends Component {
$pageCount = intval(ceil($count / $limit));
$requestedPage = $page;
$page = max(min($page, $pageCount), 1);
- if ($requestedPage > $page) {
- throw new NotFoundException();
- }
$paging = array(
'page' => $page,
@@ -237,6 +234,10 @@ class PaginatorComponent extends Component {
array($object->alias => $paging)
);
+ if ($requestedPage > $page) {
+ throw new NotFoundException();
+ }
+
if (
!in_array('Paginator', $this->Controller->helpers) &&
!array_key_exists('Paginator', $this->Controller->helpers)
diff --git a/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php b/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php
index 8bd29a030..65a7f4f00 100644
--- a/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php
+++ b/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php
@@ -919,7 +919,6 @@ class PaginatorComponentTest extends CakeTestCase {
/**
* testOutOfRangePageNumberAndPageCountZero
*
- * @expectedException NotFoundException
* @return void
*/
public function testOutOfRangePageNumberAndPageCountZero() {
@@ -933,7 +932,17 @@ class PaginatorComponentTest extends CakeTestCase {
$Controller->paginate = array(
'conditions' => array('PaginatorControllerPost.id >' => 100)
);
- $Controller->Paginator->paginate('PaginatorControllerPost');
+
+ try {
+ $Controller->Paginator->paginate('PaginatorControllerPost');
+ $this->fail();
+ } catch (NotFoundException $e) {
+ $this->assertEquals(
+ 1,
+ $Controller->request->params['paging']['PaginatorControllerPost']['page'],
+ 'Page number should not be 0'
+ );
+ }
}
/**
diff --git a/lib/Cake/Test/Case/View/Helper/TextHelperTest.php b/lib/Cake/Test/Case/View/Helper/TextHelperTest.php
index ea5a07e4c..73c021c74 100644
--- a/lib/Cake/Test/Case/View/Helper/TextHelperTest.php
+++ b/lib/Cake/Test/Case/View/Helper/TextHelperTest.php
@@ -142,7 +142,27 @@ class TextHelperTest extends CakeTestCase {
$expected = 'This is a test text with URL http://www.cakephp.org(and some more text)';
$result = $this->Text->autoLink($text);
$this->assertEquals($expected, $result);
+ }
+/**
+ * Test mixing URLs and Email addresses in one confusing string.
+ *
+ * @return void
+ */
+ public function testAutoLinkMixed() {
+ $text = 'Text with a url/email http://example.com/store?email=mark@example.com and email.';
+ $expected = 'Text with a url/email ' .
+ 'http://example.com/store?email=mark@example.com and email.';
+ $result = $this->Text->autoLink($text);
+ $this->assertEquals($expected, $result);
+ }
+
+/**
+ * test autoLink() and options.
+ *
+ * @return void
+ */
+ public function testAutoLinkOptions() {
$text = 'This is a test text with URL http://www.cakephp.org';
$expected = 'This is a test text with URL http://www.cakephp.org';
$result = $this->Text->autoLink($text, array('class' => 'link'));
@@ -246,7 +266,7 @@ class TextHelperTest extends CakeTestCase {
array(
'Text with a partial http://www.küchenschöhn-not-working.de URL',
'Text with a partial http://www.küchenschöhn-not-working.de URL'
- )
+ ),
);
}
@@ -343,10 +363,25 @@ class TextHelperTest extends CakeTestCase {
$result = $this->Text->autoLinkUrls($text);
$this->assertEquals($expected, $result);
- $text = 'Text with email@example.com address';
- $expected = 'Text with email@example.com address';
+ $text = 'email@example.com address';
+ $expected = 'email@example.com address';
$result = $this->Text->autoLinkEmails($text);
- $this->assertRegExp('#^' . $expected . '$#', $result);
+ $this->assertEquals($expected, $result);
+
+ $text = 'email@example.com address';
+ $expected = 'email@example.com address';
+ $result = $this->Text->autoLinkEmails($text);
+ $this->assertEquals($expected, $result);
+
+ $text = '(email@example.com) address';
+ $expected = '(email@example.com) address';
+ $result = $this->Text->autoLinkEmails($text);
+ $this->assertEquals($expected, $result);
+
+ $text = 'Text with email@example.com address';
+ $expected = 'Text with email@example.com address';
+ $result = $this->Text->autoLinkEmails($text);
+ $this->assertEquals($expected, $result);
$text = "Text with o'hare._-bob@example.com address";
$expected = 'Text with o'hare._-bob@example.com address';
@@ -354,19 +389,19 @@ class TextHelperTest extends CakeTestCase {
$this->assertEquals($expected, $result);
$text = 'Text with email@example.com address';
- $expected = 'Text with email@example.com address';
+ $expected = 'Text with email@example.com address';
$result = $this->Text->autoLinkEmails($text, array('class' => 'link'));
- $this->assertRegExp('#^' . $expected . '$#', $result);
+ $this->assertEquals($expected, $result);
$text = 'Text with düsentrieb@küchenschöhn-not-working.de address';
$expected = 'Text with düsentrieb@küchenschöhn-not-working.de address';
$result = $this->Text->autoLinkEmails($text);
- $this->assertRegExp('#^' . $expected . '$#', $result);
+ $this->assertEquals($expected, $result);
$text = 'Text with me@subdomain.küchenschöhn.de address';
$expected = 'Text with me@subdomain.küchenschöhn.de address';
$result = $this->Text->autoLinkEmails($text);
- $this->assertRegExp('#^' . $expected . '$#', $result);
+ $this->assertEquals($expected, $result);
}
/**
diff --git a/lib/Cake/View/Helper/TextHelper.php b/lib/Cake/View/Helper/TextHelper.php
index f40a93aaa..a3f07856c 100644
--- a/lib/Cake/View/Helper/TextHelper.php
+++ b/lib/Cake/View/Helper/TextHelper.php
@@ -187,7 +187,7 @@ class TextHelper extends AppHelper {
$atom = '[\p{L}0-9!#$%&\'*+\/=?^_`{|}~-]';
$text = preg_replace_callback(
- '/(' . $atom . '+(?:\.' . $atom . '+)*@[\p{L}0-9-]+(?:\.[\p{L}0-9-]+)+)/ui',
+ '/(?<=\s|^|\()(' . $atom . '*(?:\.' . $atom . '+)*@[\p{L}0-9-]+(?:\.[\p{L}0-9-]+)+)/ui',
array(&$this, '_insertPlaceholder'),
$text
);
diff --git a/lib/Cake/View/View.php b/lib/Cake/View/View.php
index 93be468ac..f3af7dc6c 100644
--- a/lib/Cake/View/View.php
+++ b/lib/Cake/View/View.php
@@ -1095,7 +1095,7 @@ class View extends Object {
* Return all possible paths to find view files in order
*
* @param string $plugin Optional plugin name to scan for view files.
- * @param boolean $cached Set to true to force a refresh of view paths.
+ * @param boolean $cached Set to false to force a refresh of view paths. Default true.
* @return array paths
*/
protected function _paths($plugin = null, $cached = true) {