public function DomainPart::checkIPV6Tag in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/egulias/email-validator/src/Egulias/EmailValidator/Parser/DomainPart.php \Egulias\EmailValidator\Parser\DomainPart::checkIPV6Tag()
1 call to DomainPart::checkIPV6Tag()
- DomainPart::doParseDomainLiteral in vendor/
egulias/ email-validator/ src/ Egulias/ EmailValidator/ Parser/ DomainPart.php
File
- vendor/
egulias/ email-validator/ src/ Egulias/ EmailValidator/ Parser/ DomainPart.php, line 60
Class
Namespace
Egulias\EmailValidator\ParserCode
public function checkIPV6Tag($addressLiteral, $maxGroups = 8) {
$prev = $this->lexer
->getPrevious();
if ($prev['type'] === EmailLexer::S_COLON) {
$this->warnings[] = EmailValidator::RFC5322_IPV6_COLONEND;
}
$IPv6 = substr($addressLiteral, 5);
//Daniel Marschall's new IPv6 testing strategy
$matchesIP = explode(':', $IPv6);
$groupCount = count($matchesIP);
$colons = strpos($IPv6, '::');
if (count(preg_grep('/^[0-9A-Fa-f]{0,4}$/', $matchesIP, PREG_GREP_INVERT)) !== 0) {
$this->warnings[] = EmailValidator::RFC5322_IPV6_BADCHAR;
}
if ($colons === false) {
// We need exactly the right number of groups
if ($groupCount !== $maxGroups) {
$this->warnings[] = EmailValidator::RFC5322_IPV6_GRPCOUNT;
}
return;
}
if ($colons !== strrpos($IPv6, '::')) {
$this->warnings[] = EmailValidator::RFC5322_IPV6_2X2XCOLON;
return;
}
if ($colons === 0 || $colons === strlen($IPv6) - 2) {
// RFC 4291 allows :: at the start or end of an address
//with 7 other groups in addition
++$maxGroups;
}
if ($groupCount > $maxGroups) {
$this->warnings[] = EmailValidator::RFC5322_IPV6_MAXGRPS;
}
elseif ($groupCount === $maxGroups) {
$this->warnings[] = EmailValidator::RFC5321_IPV6DEPRECATED;
}
}