Open
Description
What steps will reproduce the problem?
Fatal error occurs if used PHP, IDN enabled and domain name length is exactly 255 characters in ASCII representation.
use kdn\yii2\validators\DomainValidator;
$validator = new DomainValidator(['enableIDN' => true]);
// 255 ASCII characters
$validator->validate(str_repeat('a.', 126) . 'aaa', $error);
echo $error;
Other way
use kdn\yii2\validators\DomainValidator;
$validator = new DomainValidator(['enableIDN' => true]);
// "ф" is cyrillic symbol, only 69 characters, but after conversion to ASCII will be 255
$validator->validate(str_repeat('ф.', 31) . 's.s.s.s', $error);
echo $error;
What is the expected result?
the input value is too long.
What do you get instead?
Fatal error: idn_to_ascii(): ICU returned an unexpected length.
Additional info
Q | A |
---|---|
Extension version | All |
Yii version | All |
PHP version | All |
HHVM version | - |
Operating system | All |
Solution
There was bug in PHP function idn_to_ascii
, it was fixed in PHP 5.6 and PHP 7, please upgrade PHP or consider switching to HHVM.