Fixes #3288, Erroneous URL validation

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5790 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-10-19 04:01:04 +00:00
parent 34380bf243
commit d9f5bb7a35

View file

@ -460,10 +460,8 @@ class Validation extends Object {
return true; return true;
} }
} }
return false; return false;
} }
/** /**
* Check that value is exactly $comparedTo. * Check that value is exactly $comparedTo.
* *
@ -475,7 +473,6 @@ class Validation extends Object {
function equalTo($check, $comparedTo) { function equalTo($check, $comparedTo) {
} }
/** /**
* Check that value is a file. * Check that value is a file.
* *
@ -530,7 +527,6 @@ class Validation extends Object {
$length = strlen($check); $length = strlen($check);
return ($length <= $max); return ($length <= $max);
} }
/** /**
* Checks that a value is a monetary amount. * Checks that a value is a monetary amount.
* *
@ -551,7 +547,6 @@ class Validation extends Object {
} }
return $this->_check(); return $this->_check();
} }
/** /**
* Validate a multiple select. * Validate a multiple select.
* *
@ -566,7 +561,6 @@ class Validation extends Object {
//Validate a select against a list of restriced indexes. //Validate a select against a list of restriced indexes.
//Validate a multiple-select for the quantity selected. //Validate a multiple-select for the quantity selected.
} }
/** /**
* Validate that a number is in specified range. * Validate that a number is in specified range.
* *
@ -584,7 +578,6 @@ class Validation extends Object {
} }
} }
/** /**
* Checks if a value is numeric. * Checks if a value is numeric.
* *
@ -595,7 +588,6 @@ class Validation extends Object {
function numeric($check) { function numeric($check) {
return is_numeric($check); return is_numeric($check);
} }
/** /**
* Check that a value is a valid phone number. * Check that a value is a valid phone number.
* *
@ -623,7 +615,6 @@ class Validation extends Object {
} }
return $this->_check(); return $this->_check();
} }
/** /**
* Checks that a given value is a valid postal code. * Checks that a given value is a valid postal code.
* *
@ -657,7 +648,6 @@ class Validation extends Object {
} }
return $this->_check(); return $this->_check();
} }
/** /**
* Checks that a value is a valid Social Security Number. * Checks that a value is a valid Social Security Number.
* *
@ -691,7 +681,6 @@ class Validation extends Object {
} }
return $this->_check(); return $this->_check();
} }
/** /**
* Checks that a value is a valid URL. * Checks that a value is a valid URL.
* *
@ -701,10 +690,11 @@ class Validation extends Object {
*/ */
function url($check) { function url($check) {
$this->check = $check; $this->check = $check;
$this->regex = '/\\A(?:(https?|ftps?|file|news|gopher):\\/\\/[\\w\\-_]+(\\.[\\w\\-_]+)+([\\w\\-\\.,\'@?^=%&:;\/~\\+#]*[\\w\\-\\@?^=%&\/~\\+#])?)\\z/i'; $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)'
return $this->_check(); . '|(?:[0-9a-z]{1}[0-9a-z\\-]*\\.)+(?:[0-9a-z]{1}[0-9a-z\\-]{0,56})\\.(?:[a-z]{2,6}|[a-z]{2}\\.[a-z]{2,6})'
. '(?::[0-9]{1,4})?)(?:\\/?|\\/[\\w\\-\\.,\'@?^=%&:;\/~\\+#]*[\\w\\-\\@?^=%&\/~\\+#])$/i';
return $this->_check();
} }
/** /**
* Runs an user-defined validation. * Runs an user-defined validation.
* *
@ -718,7 +708,6 @@ class Validation extends Object {
function userDefined($check, $object, $method, $args = null) { function userDefined($check, $object, $method, $args = null) {
return call_user_func_array(array(&$object, $method), array($check,$args)); return call_user_func_array(array(&$object, $method), array($check,$args));
} }
/** /**
* Runs a regular expression match. * Runs a regular expression match.
* *
@ -734,7 +723,6 @@ class Validation extends Object {
return false; return false;
} }
} }
/** /**
* Get the values to use when value sent to validation method is * Get the values to use when value sent to validation method is
* an array. * an array.
@ -795,7 +783,6 @@ class Validation extends Object {
} }
return true; return true;
} }
/** /**
* Reset internal variables for another validation run. * Reset internal variables for another validation run.
* *