egulias / EmailValidator4J

Java RFC strict EmailValidator
MIT License
25 stars 8 forks source link

Domains with hyphens are broken in 1.0.2 #10

Closed AlainODea closed 5 years ago

AlainODea commented 5 years ago

In fixing one issue with hyphens, I created another.

Domains like has-hyphen.example.com will fail with a stacktrace like this:

emailvalidator4j.parser.exception.DomainHyphen: Found -  in domain part
    at emailvalidator4j.parser.DomainPart.doParseDomainPart(DomainPart.java:59)
    at emailvalidator4j.parser.DomainPart.parse(DomainPart.java:39)

I'll follow up with a fix.

AlainODea commented 5 years ago

Also domains with leading numbers are also broken. Sorry :sweat_smile:

AlainODea commented 5 years ago

The leading numbers are broken because the lexer doesn't allow mixed numbers and letters in a single GENERIC and my code blocks consecutive generic RFC 5322 section 3.2.3 defines atext in a way that explicitly allows that. I've corrected the regex and it passes all of the existing tests. I'm going to write some additional test cases to mitigate the risk that I break something new again.