mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-08-28 02:58:29 +00:00
Domain back slash (#108)
* New home for all the tests. Fixed namespaces * small code improvement * Skipping tests failing only in Travis * Add backslash as a forbbiden char
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Egulias\EmailValidator\Parser;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
@@ -133,9 +132,7 @@ class DomainPart extends Parser
|
||||
do {
|
||||
$prev = $this->lexer->getPrevious();
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_SLASH) {
|
||||
throw new CharNotAllowed();
|
||||
}
|
||||
$this->checkNotAllowedChars($this->lexer->token);
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) {
|
||||
$this->parseComments();
|
||||
@@ -173,6 +170,14 @@ class DomainPart extends Parser
|
||||
|
||||
return $domain;
|
||||
}
|
||||
|
||||
private function checkNotAllowedChars($token)
|
||||
{
|
||||
$notAllowed = [EmailLexer::S_BACKSLASH => true, EmailLexer::S_SLASH=> true];
|
||||
if (isset($notAllowed[$token['type']])) {
|
||||
throw new CharNotAllowed();
|
||||
}
|
||||
}
|
||||
|
||||
protected function parseDomainLiteral()
|
||||
{
|
||||
|
||||
@@ -25,6 +25,7 @@ class MultipleValidationWithAnd implements EmailValidation
|
||||
$result = true;
|
||||
$errors = [];
|
||||
foreach ($this->validations as $validation) {
|
||||
$emailLexer->reset();
|
||||
$result = $result && $validation->isValid($email, $emailLexer);
|
||||
$this->warnings = array_merge($this->warnings, $validation->getWarnings());
|
||||
$errors[] = $validation->getError();
|
||||
|
||||
@@ -127,6 +127,7 @@ class RFCValidationTest extends \PHPUnit_Framework_TestCase
|
||||
['.example@localhost'],
|
||||
['ex\ample@localhost'],
|
||||
['example@local\host'],
|
||||
['example@localhost\\'],
|
||||
['example@localhost.'],
|
||||
['user name@example.com'],
|
||||
['username@ example . com'],
|
||||
|
||||
Reference in New Issue
Block a user