Skip to content

Commit

Permalink
Revert "Change URL Validation to use filter_var"
Browse files Browse the repository at this point in the history
This reverts commit 4e53916.
  • Loading branch information
predominant committed Apr 24, 2010
1 parent 4e53916 commit da31033
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cake/libs/validation.php
Expand Up @@ -666,11 +666,14 @@ public static function ssn($check, $regex = null, $country = null) {
* @return boolean Success
*/
public static function url($check, $strict = false) {
$flags = array(FILTER_FLAG_HOST_REQUIRED);
if ($strict === true) {
$flags[] = FILTER_FLAG_SCHEME_REQUIRED;
}
return (boolean)filter_var($check, FILTER_VALIDATE_URL, $flags);
self::__populateIp();
$validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=~') . '\/0-9a-z]|(%[0-9a-f]{2}))';
$regex = '/^(?:(?:https?|ftps?|file|news|gopher):\/\/)' . (!empty($strict) ? '' : '?') .
'(?:' . self::$__pattern['IPv4'] . '|' . self::$__pattern['hostname'] . ')(?::[1-9][0-9]{0,3})?' .
'(?:\/?|\/' . $validChars . '*)?' .
'(?:\?' . $validChars . '*)?' .
'(?:#' . $validChars . '*)?$/i';
return self::_check($check, $regex);
}

/**
Expand Down

0 comments on commit da31033

Please sign in to comment.