unclosed comment

This commit is contained in:
Eduardo Gulias Davis
2015-06-26 14:52:06 +02:00
parent a9d35f2e2c
commit 5f813d9511
4 changed files with 15 additions and 3 deletions
@@ -11,7 +11,6 @@ use Egulias\EmailValidator\InvalidEmail;
*/
class EmailValidator
{
const ERR_UNCLOSEDCOMMENT = 146;
const ERR_UNCLOSEDDOMLIT = 147;
const ERR_FWS_CRLF_X2 = 148;
const ERR_FWS_CRLF_END = 149;
@@ -0,0 +1,11 @@
<?php
namespace Egulias\EmailValidator\Exception;
use Egulias\EmailValidator\InvalidEmail;
class UnclosedComment extends InvalidEmail
{
const CODE = 146;
const REASON = "No colosing comment token found";
}
+2 -1
View File
@@ -9,6 +9,7 @@ use Egulias\EmailValidator\Exception\ConsecutiveDot;
use Egulias\EmailValidator\Exception\ExpectedQPair;
use Egulias\EmailValidator\Exception\ExpectingATEXT;
use Egulias\EmailValidator\Exception\ExpectingCTEXT;
use Egulias\EmailValidator\Exception\UnclosedComment;
use Egulias\EmailValidator\Exception\UnclosedQuotedString;
abstract class Parser
@@ -70,7 +71,7 @@ abstract class Parser
$this->lexer->find(EmailLexer::S_CLOSEPARENTHESIS);
return true;
} catch (\RuntimeException $e) {
throw new \InvalidArgumentException('ERR_UNCLOSEDCOMMENT');
throw new UnclosedComment();
}
}
@@ -13,6 +13,7 @@ use Egulias\EmailValidator\Exception\ExpectingATEXT;
use Egulias\EmailValidator\Exception\ExpectingDTEXT;
use Egulias\EmailValidator\Exception\NoDomainPart;
use Egulias\EmailValidator\Exception\NoLocalPart;
use Egulias\EmailValidator\Exception\UnclosedComment;
use Egulias\EmailValidator\Exception\UnclosedQuotedString;
class EmailValidatorTest extends \PHPUnit_Framework_TestCase
@@ -162,7 +163,7 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase
array(DotAtStart::CODE, 'example@.localhost'),
array(DotAtEnd::CODE, 'example@localhost.'),
array(DotAtEnd::CODE, 'example.@example.co.uk'),
array(EmailValidator::ERR_UNCLOSEDCOMMENT, '(example@localhost'),
array(UnclosedComment::CODE, '(example@localhost'),
array(UnclosedQuotedString::CODE, '"example@localhost'),
array(ExpectingATEXT::CODE, 'exa"mple@localhost'),
//This was the original. But atext is not allowed after \n