From ccdbbe1f344bd8072b9f645c1e1a55178d9c3ec3 Mon Sep 17 00:00:00 2001 From: Anton Nguyen Date: Sat, 7 Oct 2017 10:41:19 -0400 Subject: [PATCH] Allow utf8mb4 characters in the URL refs #8368 --- src/Validation/Validation.php | 4 +++- tests/TestCase/Validation/ValidationTest.php | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Validation/Validation.php b/src/Validation/Validation.php index 06a6c5f6fe9..77340f6ab71 100644 --- a/src/Validation/Validation.php +++ b/src/Validation/Validation.php @@ -908,7 +908,9 @@ public static function range($check, $lower = null, $upper = null) public static function url($check, $strict = false) { static::_populateIp(); - $alpha = '0-9\p{L}\p{N}'; + + $emoji = '\x{1F300}-\x{1F6FF}'; + $alpha = '0-9(\p{L}\p{N}' . $emoji; $hex = '(%[0-9a-f]{2})'; $subDelimiters = preg_quote('/!"$&\'()*+,-.@_:;=~[]', '/'); $path = '([' . $subDelimiters . $alpha . ']|' . $hex . ')'; diff --git a/tests/TestCase/Validation/ValidationTest.php b/tests/TestCase/Validation/ValidationTest.php index 778b631e70c..0558146ec3f 100644 --- a/tests/TestCase/Validation/ValidationTest.php +++ b/tests/TestCase/Validation/ValidationTest.php @@ -2181,6 +2181,7 @@ public function testUrl() $this->assertTrue(Validation::url('http://www.electrohome.ro/images/239537750-284232-215_300[1].jpg')); $this->assertTrue(Validation::url('http://www.eräume.foo')); $this->assertTrue(Validation::url('http://äüö.eräume.foo')); + $this->assertTrue(Validation::url('http://www.domain.com/👹'), 'utf8Extended path failed'); $this->assertTrue(Validation::url('http://cakephp.org:80')); $this->assertTrue(Validation::url('http://cakephp.org:443'));