File tree Expand file tree Collapse file tree 4 files changed +21
-1
lines changed
main/java/emailvalidator4j
test/java/emailvalidator4j/parser Expand file tree Collapse file tree 4 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ public class EmailLexer {
1616
1717 public void lex (String input ) {
1818 Pattern pattern = Pattern .compile (
19- "([a-zA-Z_]+[46]?)|([0-9]+)|(\r \n )|(::)|(\\ s+?)|(.)|(\\ p{Cc}+)" , Pattern .CASE_INSENSITIVE | Pattern .UNICODE_CASE
19+ "(( [a-zA-Z_]|[^ \\ u0000- \\ u007F]) +[46]?)|([0-9]+)|(\r \n )|(::)|(\\ s+?)|(.)|(\\ p{Cc}+)" , Pattern .CASE_INSENSITIVE | Pattern .UNICODE_CASE
2020 );
2121 Matcher matcher = pattern .matcher (input );
2222
Original file line number Diff line number Diff line change @@ -55,6 +55,10 @@ private void doParseDomainPart() throws InvalidEmail {
5555 int domainPartOpenedParenthesis = 0 ;
5656 boolean openBrackets = false ;
5757 do {
58+ if (this .lexer .getCurrent ().equals (Tokens .HYPHEN )) {
59+ throw new DomainHyphen ("Found - in domain part" );
60+ }
61+
5862 if (this .lexer .getCurrent ().equals (Tokens .SEMICOLON )) {
5963 throw new ExpectedATEXT ("Expected ATEXT" );
6064 }
@@ -149,6 +153,11 @@ private void checkExceptions() throws InvalidEmail {
149153 if (this .lexer .getCurrent ().equals (Tokens .BACKSLASH ) && this .lexer .isNextToken (Tokens .get ("GENERIC" ))) {
150154 throw new ExpectedATEXT ("Found BACKSLASH" );
151155 }
156+
157+ if (this .lexer .getCurrent ().equals (Tokens .get ("GENERIC" )) && this .lexer .isNextToken (Tokens .get ("GENERIC" ))) {
158+ this .lexer .next ();
159+ throw new ConsecutiveGeneric ("Found " + this .lexer .getCurrent ().getText ());
160+ }
152161 }
153162
154163 private void checkIPv6Tag (String literal ) {
Original file line number Diff line number Diff line change 1+ package emailvalidator4j .parser .exception ;
2+
3+ public class ConsecutiveGeneric extends InvalidEmail {
4+ public ConsecutiveGeneric (String message ) {
5+ super (message );
6+ }
7+ }
Original file line number Diff line number Diff line change @@ -47,10 +47,14 @@ public static Object[][] invalidDomainParts() {
4747 {ConsecutiveAT .class , "@@start" },
4848 {ExpectedATEXT .class , "@at[start" },
4949 {DomainHyphen .class , "@atstart-.com" },
50+ {DomainHyphen .class , "@bb.-cc" },
51+ {DomainHyphen .class , "@bb.-cc-" },
52+ {DomainHyphen .class , "@bb.cc-" },
5053 {DomainNotAllowedCharacter .class , "@atst\\ art.com" },
5154 {DomainNotAllowedCharacter .class , "@example\\ " },
5255 {DomainNotAllowedCharacter .class , "@exa\\ mple" },
5356 {UnclosedDomainLiteral .class , "@example]" },
57+ {ConsecutiveGeneric .class , "@example'" },
5458 };
5559 }
5660
You can’t perform that action at this time.
0 commit comments