From a9d35f2e2c15e7206d7c8d8d0e3aff8e7f6d6791 Mon Sep 17 00:00:00 2001 From: Eduardo Gulias Davis Date: Fri, 26 Jun 2015 14:45:02 +0200 Subject: [PATCH] Unclosed quoted string --- src/Egulias/EmailValidator/EmailValidator.php | 1 - .../Exception/UnclosedQuotedString.php | 12 ++++++++++++ src/Egulias/EmailValidator/Parser/Parser.php | 3 ++- .../Tests/EmailValidator/EmailValidatorTest.php | 3 ++- 4 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 src/Egulias/EmailValidator/Exception/UnclosedQuotedString.php diff --git a/src/Egulias/EmailValidator/EmailValidator.php b/src/Egulias/EmailValidator/EmailValidator.php index 40892df..94e6724 100644 --- a/src/Egulias/EmailValidator/EmailValidator.php +++ b/src/Egulias/EmailValidator/EmailValidator.php @@ -11,7 +11,6 @@ use Egulias\EmailValidator\InvalidEmail; */ class EmailValidator { - const ERR_UNCLOSEDQUOTEDSTR = 145; const ERR_UNCLOSEDCOMMENT = 146; const ERR_UNCLOSEDDOMLIT = 147; const ERR_FWS_CRLF_X2 = 148; diff --git a/src/Egulias/EmailValidator/Exception/UnclosedQuotedString.php b/src/Egulias/EmailValidator/Exception/UnclosedQuotedString.php new file mode 100644 index 0000000..949dd2d --- /dev/null +++ b/src/Egulias/EmailValidator/Exception/UnclosedQuotedString.php @@ -0,0 +1,12 @@ +lexer->find(EmailLexer::S_DQUOTE); $hasClosingQuote = true; } catch (\Exception $e) { - throw new \InvalidArgumentException('ERR_UNCLOSEDQUOTEDSTR'); + throw new UnclosedQuotedString(); } return $hasClosingQuote; diff --git a/tests/egulias/Tests/EmailValidator/EmailValidatorTest.php b/tests/egulias/Tests/EmailValidator/EmailValidatorTest.php index 17700b0..560e10f 100644 --- a/tests/egulias/Tests/EmailValidator/EmailValidatorTest.php +++ b/tests/egulias/Tests/EmailValidator/EmailValidatorTest.php @@ -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\UnclosedQuotedString; class EmailValidatorTest extends \PHPUnit_Framework_TestCase { @@ -162,7 +163,7 @@ class EmailValidatorTest extends \PHPUnit_Framework_TestCase array(DotAtEnd::CODE, 'example@localhost.'), array(DotAtEnd::CODE, 'example.@example.co.uk'), array(EmailValidator::ERR_UNCLOSEDCOMMENT, '(example@localhost'), - array(EmailValidator::ERR_UNCLOSEDQUOTEDSTR, '"example@localhost'), + array(UnclosedQuotedString::CODE, '"example@localhost'), array(ExpectingATEXT::CODE, 'exa"mple@localhost'), //This was the original. But atext is not allowed after \n //array(EmailValidator::ERR_EXPECTING_ATEXT, "exampl\ne@example.co.uk"),