Skip to content

Commit

Permalink
Adding tilde (~) to accepted characters for URL validation. Fixes #52,…
Browse files Browse the repository at this point in the history
… and legacy trac enhancement 6213.
  • Loading branch information
jperras committed Sep 19, 2009
1 parent d5376e6 commit ca63246
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cake/libs/validation.php
Expand Up @@ -843,7 +843,7 @@ function ssn($check, $regex = null, $country = null) {
function url($check, $strict = false) {
$_this =& Validation::getInstance();
$_this->check = $check;
$validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=') . '\/0-9a-z]|(%[0-9a-f]{2}))';
$validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=~') . '\/0-9a-z]|(%[0-9a-f]{2}))';
$_this->regex = '/^(?:(?:https?|ftps?|file|news|gopher):\/\/)' . (!empty($strict) ? '' : '?') .
'(?:' . $_this->__pattern['ip'] . '|' . $_this->__pattern['hostname'] . ')(?::[1-9][0-9]{0,3})?' .
'(?:\/?|\/' . $validChars . '*)?' .
Expand Down
1 change: 1 addition & 0 deletions cake/tests/cases/libs/validation.test.php
Expand Up @@ -1755,6 +1755,7 @@ function testUrl() {
$this->assertFalse(Validation::url('http://en.(wikipedia).org/'));
$this->assertFalse(Validation::url('www.cakephp.org', true));
$this->assertTrue(Validation::url('http://www.cakephp.org', true));
$this->assertTrue(Validation::url('http://example.com/~userdir/'));
}

/**
Expand Down

0 comments on commit ca63246

Please sign in to comment.