diff --git a/yii/assets/yii.validation.js b/yii/assets/yii.validation.js index d173e9b..c9d62bd 100644 --- a/yii/assets/yii.validation.js +++ b/yii/assets/yii.validation.js @@ -112,8 +112,9 @@ yii.validation = (function ($) { var valid = true; - if (options.idn) { - var regexp = /^(.*)@(.*)$/, matches = regexp.exec(value); + if (options.enableIDN) { + var regexp = /^(.*)@(.*)$/, + matches = regexp.exec(value); if (matches === null) { valid = false; } else { @@ -137,8 +138,9 @@ yii.validation = (function ($) { var valid = true; - if (options.idn) { - var regexp = /^([^:]+):\/\/([^\/]+)(.*)?/, matches = regexp.exec(value); + if (options.enableIDN) { + var regexp = /^([^:]+):\/\/([^\/]+)(.*)?/, + matches = regexp.exec(value); if (matches === null) { valid = false; } else { diff --git a/yii/validators/EmailValidator.php b/yii/validators/EmailValidator.php index 00e9d40..f1059d7 100644 --- a/yii/validators/EmailValidator.php +++ b/yii/validators/EmailValidator.php @@ -51,7 +51,7 @@ class EmailValidator extends Validator * @var boolean whether validation process should take into account IDN (internationalized domain * names). Defaults to false meaning that validation of emails containing IDN will always fail. */ - public $idn = false; + public $enableIDN = false; /** @@ -94,7 +94,7 @@ class EmailValidator extends Validator return false; } $domain = rtrim(substr($value, $atPosition + 1), '>'); - if ($this->idn) { + if ($this->enableIDN) { $value = idn_to_ascii(ltrim(substr($value, 0, $atPosition), '<')) . '@' . idn_to_ascii($domain); } $valid = preg_match($this->pattern, $value) || $this->allowName && preg_match($this->fullPattern, $value); @@ -125,7 +125,7 @@ class EmailValidator extends Validator '{attribute}' => $object->getAttributeLabel($attribute), '{value}' => $object->$attribute, ))), - 'idn' => (boolean)$this->idn, + 'enableIDN' => (boolean)$this->enableIDN, ); if ($this->skipOnEmpty) { $options['skipOnEmpty'] = 1; diff --git a/yii/validators/UrlValidator.php b/yii/validators/UrlValidator.php index 9c3c878..ddc3e86 100644 --- a/yii/validators/UrlValidator.php +++ b/yii/validators/UrlValidator.php @@ -42,7 +42,7 @@ class UrlValidator extends Validator * domain names). Defaults to false meaning that validation of URLs containing IDN will always * fail. */ - public $idn = false; + public $enableIDN = false; /** @@ -93,7 +93,7 @@ class UrlValidator extends Validator $pattern = $this->pattern; } - if ($this->idn) { + if ($this->enableIDN) { $value = preg_replace_callback('/:\/\/([^\/]+)/', function($matches) { return '://' . idn_to_ascii($matches[1]); }, $value); @@ -127,7 +127,7 @@ class UrlValidator extends Validator '{attribute}' => $object->getAttributeLabel($attribute), '{value}' => $object->$attribute, ))), - 'idn' => (boolean)$this->idn, + 'enableIDN' => (boolean)$this->enableIDN, ); if ($this->skipOnEmpty) { $options['skipOnEmpty'] = 1; diff --git a/yii/widgets/ActiveField.php b/yii/widgets/ActiveField.php index d3716b5..d2254fe 100644 --- a/yii/widgets/ActiveField.php +++ b/yii/widgets/ActiveField.php @@ -124,7 +124,7 @@ class ActiveField extends Component $options['class'] = implode(' ', $class); foreach ($this->model->getActiveValidators($attribute) as $validator) { - if (($validator instanceof EmailValidator || $validator instanceof UrlValidator) && $validator->idn) { + if (($validator instanceof EmailValidator || $validator instanceof UrlValidator) && $validator->enableIDN) { $this->form->view->registerAssetBundle('punycode'); break; }