Skip to content

Commit

Permalink
Adding unicode letters and numbers to url path segment regex.
Browse files Browse the repository at this point in the history
Test case added.
Fixes #1284
  • Loading branch information
markstory committed Dec 2, 2010
1 parent 96b30f0 commit 44b0917
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cake/libs/validation.php
Expand Up @@ -874,13 +874,13 @@ function url($check, $strict = false) {
$_this =& Validation::getInstance();
$_this->__populateIp();
$_this->check = $check;
$validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=~') . '\/0-9a-z]|(%[0-9a-f]{2}))';
$validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=~') . '\/0-9a-z\p{L}\p{N}]|(%[0-9a-f]{2}))';
$_this->regex = '/^(?:(?:https?|ftps?|file|news|gopher):\/\/)' . (!empty($strict) ? '' : '?') .
'(?:' . $_this->__pattern['IPv4'] . '|\[' . $_this->__pattern['IPv6'] . '\]|' . $_this->__pattern['hostname'] . ')' .
'(?::[1-9][0-9]{0,4})?' .
'(?:\/?|\/' . $validChars . '*)?' .
'(?:\?' . $validChars . '*)?' .
'(?:#' . $validChars . '*)?$/i';
'(?:#' . $validChars . '*)?$/iu';
return $_this->_check();
}

Expand Down
1 change: 1 addition & 0 deletions cake/tests/cases/libs/validation.test.php
Expand Up @@ -1879,6 +1879,7 @@ function testUrl() {
$this->assertTrue(Validation::url('http://example.com/~userdir/subdir/index.html'));
$this->assertTrue(Validation::url('http://www.zwischenraume.de'));
$this->assertTrue(Validation::url('http://www.zwischenraume.cz'));
$this->assertTrue(Validation::url('http://www.last.fm/music/浜崎あゆみ'), 'utf8 path failed');

$this->assertTrue(Validation::url('http://cakephp.org:80'));
$this->assertTrue(Validation::url('http://cakephp.org:443'));
Expand Down

0 comments on commit 44b0917

Please sign in to comment.