function Idn::validateBidiLabel
Parameters
string $label:
See also
https://tools.ietf.org/html/rfc5893#section-2
1 call to Idn::validateBidiLabel()
- Idn::validateLabel in vendor/
symfony/ polyfill-intl-idn/ Idn.php
File
-
vendor/
symfony/ polyfill-intl-idn/ Idn.php, line 388
Class
- Idn
- @internal
Namespace
Symfony\Polyfill\Intl\IdnCode
private static function validateBidiLabel($label, Info $info) {
if (1 === preg_match(Regex::RTL_LABEL, $label)) {
$info->bidiDomain = true;
// Step 1. The first character must be a character with Bidi property L, R, or AL.
// If it has the R or AL property, it is an RTL label
if (1 !== preg_match(Regex::BIDI_STEP_1_RTL, $label)) {
$info->validBidiDomain = false;
return;
}
// Step 2. In an RTL label, only characters with the Bidi properties R, AL, AN, EN, ES,
// CS, ET, ON, BN, or NSM are allowed.
if (1 === preg_match(Regex::BIDI_STEP_2, $label)) {
$info->validBidiDomain = false;
return;
}
// Step 3. In an RTL label, the end of the label must be a character with Bidi property
// R, AL, EN, or AN, followed by zero or more characters with Bidi property NSM.
if (1 !== preg_match(Regex::BIDI_STEP_3, $label)) {
$info->validBidiDomain = false;
return;
}
// Step 4. In an RTL label, if an EN is present, no AN may be present, and vice versa.
if (1 === preg_match(Regex::BIDI_STEP_4_AN, $label) && 1 === preg_match(Regex::BIDI_STEP_4_EN, $label)) {
$info->validBidiDomain = false;
return;
}
return;
}
// We are a LTR label
// Step 1. The first character must be a character with Bidi property L, R, or AL.
// If it has the L property, it is an LTR label.
if (1 !== preg_match(Regex::BIDI_STEP_1_LTR, $label)) {
$info->validBidiDomain = false;
return;
}
// Step 5. In an LTR label, only characters with the Bidi properties L, EN,
// ES, CS, ET, ON, BN, or NSM are allowed.
if (1 === preg_match(Regex::BIDI_STEP_5, $label)) {
$info->validBidiDomain = false;
return;
}
// Step 6.In an LTR label, the end of the label must be a character with Bidi property L or
// EN, followed by zero or more characters with Bidi property NSM.
if (1 !== preg_match(Regex::BIDI_STEP_6, $label)) {
$info->validBidiDomain = false;
return;
}
}