From ea30a48c5ad1ad347f5c6f03b381c1f1c9d8d852 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 5 Nov 2008 03:49:55 +0000 Subject: [PATCH] Fixing validation of URLs with round brackets. Patch from 'dho' added. Closes #5685 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7826 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/validation.php | 6 +++--- cake/tests/cases/libs/validation.test.php | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cake/libs/validation.php b/cake/libs/validation.php index b95027bb6..dfb49cb6a 100644 --- a/cake/libs/validation.php +++ b/cake/libs/validation.php @@ -1,7 +1,7 @@ check = $check; $_this->regex = '/^(?:(?:https?|ftps?|file|news|gopher):\\/\\/)?(?:(?:(?:25[0-5]|2[0-4]\d|(?:(?:1\d)?|[1-9]?)\d)\.){3}(?:25[0-5]|2[0-4]\d|(?:(?:1\d)?|[1-9]?)\d)' - . '|(?:[0-9a-z]{1}[0-9a-z\\-]*\\.)*(?:[0-9a-z]{1}[0-9a-z\\-]{0,62})\\.(?:[a-z]{2,6}|[a-z]{2}\\.[a-z]{2,6})' - . '(?::[0-9]{1,4})?)(?:\\/?|\\/[\\w\\-\\.,\'@?^=%&:;\/~\\+#]*[\\w\\-\\@?^=%&\/~\\+#])$/i'; + . '|(?:[0-9a-z]{1}[0-9a-z\\-]*\\.)*(?:[0-9a-z]{1}[0-9a-z\\-]{0,62})\\.(?:[a-z]{2,6}|[a-z]{2}\\.[a-z]{2,6})' + . '(?::[0-9]{1,4})?)(?:\\/?|\\/[\\w\\-\\.,\'@?^=%&:;\/~\\+\(\)#]*[\\w\\-\\@?^=%&\/~\\+\(\)#])$/i'; return $_this->_check(); } /** diff --git a/cake/tests/cases/libs/validation.test.php b/cake/tests/cases/libs/validation.test.php index 0db379d41..c0d954fff 100644 --- a/cake/tests/cases/libs/validation.test.php +++ b/cake/tests/cases/libs/validation.test.php @@ -1,7 +1,7 @@ assertTrue(Validation::url('http://123456789112345678921234567893123456789412345678951234567896123.com')); $this->assertFalse(Validation::url('http://this-domain-is-too-loooooong-by-icann-rules-maximum-length-is-63.com')); $this->assertTrue(Validation::url('http://www.domain.com/blogs/index.php?blog=6&tempskin=_rss2')); + $this->assertTrue(Validation::url('http://en.wikipedia.org/wiki/Architectural_pattern_(computer_science)')); + $this->assertFalse(Validation::url('http://en.(wikipedia).org/')); } /** * testInList method