mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-03 10:02:42 +00:00
Allow international domains to pass validation. Fixes #1763
This commit is contained in:
parent
ee0ed3a43a
commit
ed2054f4f2
2 changed files with 10 additions and 4 deletions
|
@ -39,7 +39,7 @@ class Validation {
|
|||
* @var array
|
||||
*/
|
||||
protected static $_pattern = array(
|
||||
'hostname' => '(?:[_a-z0-9][-_a-z0-9]*\.)*(?:[a-z0-9][-a-z0-9]{0,62})\.(?:(?:[a-z]{2}\.)?[a-z]{2,})'
|
||||
'hostname' => '(?:[_\p{L}0-9][-_\p{L}0-9]*\.)*(?:[\p{L}0-9][-\p{L}0-9]{0,62})\.(?:(?:[a-z]{2}\.)?[a-z]{2,})'
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -431,7 +431,7 @@ class Validation {
|
|||
}
|
||||
|
||||
if ($regex === null) {
|
||||
$regex = '/^[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@' . self::$_pattern['hostname'] . '$/i';
|
||||
$regex = '/^[\p{L}0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[\p{L}0-9!#$%&\'*+\/=?^_`{|}~-]+)*@' . self::$_pattern['hostname'] . '$/ui';
|
||||
}
|
||||
$return = self::_check($check, $regex);
|
||||
if ($deep === false || $deep === null) {
|
||||
|
@ -756,7 +756,7 @@ class Validation {
|
|||
*/
|
||||
public static function url($check, $strict = false) {
|
||||
self::_populateIp();
|
||||
$validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=~[]') . '\/0-9a-z\p{L}\p{N}]|(%[0-9a-f]{2}))';
|
||||
$validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=~[]') . '\/0-9\p{L}\p{N}]|(%[0-9a-f]{2}))';
|
||||
$regex = '/^(?:(?:https?|ftps?|sftp|file|news|gopher):\/\/)' . (!empty($strict) ? '' : '?') .
|
||||
'(?:' . self::$_pattern['IPv4'] . '|\[' . self::$_pattern['IPv6'] . '\]|' . self::$_pattern['hostname'] . ')(?::[1-9][0-9]{0,4})?' .
|
||||
'(?:\/?|\/' . $validChars . '*)?' .
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue