Skip to content

Validator determines reason of validation error incorrectly if used HHVM and IDN enabled. #2

Open
@dmitry-kulikov

Description

@dmitry-kulikov

What steps will reproduce the problem?

Validator determines reason of validation error incorrectly if used HHVM and IDN enabled.

use kdn\yii2\validators\DomainValidator;

$validator = new DomainValidator(['enableIDN' => true]);
$validator->validate('-example.com', $error);
echo $error;

What is the expected result?

Each label of the input value should start and end with letter or number. The rightmost label of the input value should start with letter.

What do you get instead?

the input value is too long.

Additional info

Q A
Extension version All
Yii version All
PHP version -
HHVM version All
Operating system All

Solution

There was bug in HHVM function idn_to_ascii, it was fixed. You have the following options:

  1. Upgrade to most recent version of HHVM (recommended).
  2. Set property simpleErrorMessage to true:
use kdn\yii2\validators\DomainValidator;

$validator = new DomainValidator(['enableIDN' => true, 'simpleErrorMessage' => true]);
$validator->validate('-example.com', $error);
echo $error;

Result will be the input value is invalid for all error cases. It is not perfect because doesn't explain the reason to user but correct.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions