commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1723569 - in /commons/proper/validator/trunk/src: changes/changes.xml main/java/org/apache/commons/validator/routines/EmailValidator.java test/java/org/apache/commons/validator/routines/EmailValidatorTest.java
Date Thu, 07 Jan 2016 15:09:51 GMT
Author: sebb
Date: Thu Jan  7 15:09:51 2016
New Revision: 1723569

URL: http://svn.apache.org/viewvc?rev=1723569&view=rev
Log:
VALIDATOR-359 EmailValidator does not catch invalid email address like dora@.com

Modified:
    commons/proper/validator/trunk/src/changes/changes.xml
    commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/EmailValidator.java
    commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/EmailValidatorTest.java

Modified: commons/proper/validator/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/changes/changes.xml?rev=1723569&r1=1723568&r2=1723569&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/changes/changes.xml (original)
+++ commons/proper/validator/trunk/src/changes/changes.xml Thu Jan  7 15:09:51 2016
@@ -93,6 +93,9 @@ http://commons.apache.org/validator/depe
     <action issue="VALIDATOR-386" type="fix" dev="sebb" due-to="Auke van Leeuwen">
     org.apache.commons.validator.routines.DomainValidator.ArrayType is not public
     </action>
+    <action issue="VALIDATOR-359" type="fix" dev="sebb" due-to="Dora Kinghorn">
+    EmailValidator does not catch invalid email address like dora@.com
+    </action>
     <action type="update" dev="sebb">
     Updated to TLD list Version 2016010600, Last Updated Wed Jan  6 07:07:02 2016 UTC
     </action>

Modified: commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/EmailValidator.java
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/EmailValidator.java?rev=1723569&r1=1723568&r2=1723569&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/EmailValidator.java
(original)
+++ commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/EmailValidator.java
Thu Jan  7 15:09:51 2016
@@ -199,7 +199,7 @@ public class EmailValidator implements S
         DomainValidator domainValidator =
                 DomainValidator.getInstance(allowLocal);
         if (allowTld) {
-            return domainValidator.isValid(domain) || domainValidator.isValidTld(domain);
+            return domainValidator.isValid(domain) || (!domain.startsWith(".") &&
domainValidator.isValidTld(domain));
         } else {
             return domainValidator.isValid(domain);
         }

Modified: commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/EmailValidatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/EmailValidatorTest.java?rev=1723569&r1=1723568&r2=1723569&view=diff
==============================================================================
--- commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/EmailValidatorTest.java
(original)
+++ commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/EmailValidatorTest.java
Thu Jan  7 15:09:51 2016
@@ -509,6 +509,23 @@ public class EmailValidatorTest extends
                 "Maecenaspharetraeuismodmetusegetefficitur.Suspendisseamet@gmail.com"));
     }
 
+    /**
+     * Tests the e-mail validation with a user at a TLD
+     *
+     * http://tools.ietf.org/html/rfc5321#section-2.3.5
+     * (In the case of a top-level domain used by itself in an
+     * email address, a single string is used without any dots)
+     */
+    public void testEmailAtTLD() {
+        EmailValidator val = EmailValidator.getInstance(false, true);
+        assertTrue(val.isValid("test@com"));
+    }
+
+    public void testValidator359() {
+        EmailValidator val = EmailValidator.getInstance(false, true);
+        assertFalse(val.isValid("test@.com"));
+    }
+
     public void testValidator374() {
         assertTrue(validator.isValid("abc@school.school"));
     }



Mime
View raw message