Unclosed quoted string

This commit is contained in:
Eduardo Gulias Davis
2015-06-26 14:45:02 +02:00
parent 76e52cc5ce
commit a9d35f2e2c
4 changed files with 16 additions and 3 deletions
@@ -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;
@@ -0,0 +1,12 @@
<?php
namespace Egulias\EmailValidator\Exception;
use Egulias\EmailValidator\InvalidEmail;
class UnclosedQuotedString extends InvalidEmail
{
const CODE = 145;
const REASON = "Unclosed quoted string";
}
+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\UnclosedQuotedString;
abstract class Parser
{
@@ -174,7 +175,7 @@ abstract class Parser
$this->lexer->find(EmailLexer::S_DQUOTE);
$hasClosingQuote = true;
} catch (\Exception $e) {
throw new \InvalidArgumentException('ERR_UNCLOSEDQUOTEDSTR');
throw new UnclosedQuotedString();
}
return $hasClosingQuote;
@@ -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"),