commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 29541] New: - EmailValidator allows apostrophes in domain name
Date Sat, 12 Jun 2004 20:49:14 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=29541>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=29541

EmailValidator allows apostrophes in domain name

           Summary: EmailValidator allows apostrophes in domain name
           Product: Commons
           Version: 1.1 Final
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Validator
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: mcraig@visiblepath.com


JavaMail rejects addresses with apostrophes in the domain name
(javax.mail.SendFailedException: 501 Syntax error in recipient address).  Here
is a patch to reject all domains with apostrophes.
 -micah



Index: src/share/org/apache/commons/validator/EmailValidator.java
===================================================================
RCS file:
/home/cvspublic/jakarta-commons/validator/src/share/org/apache/commons/validator/EmailValidator.java,v
retrieving revision 1.15
diff -u -r1.15 EmailValidator.java
--- src/share/org/apache/commons/validator/EmailValidator.java	8 Jun 2004
14:48:35 -0000	1.15
+++ src/share/org/apache/commons/validator/EmailValidator.java	12 Jun 2004
20:26:37 -0000
@@ -187,6 +187,10 @@
      * @param domain symbolic domain name
      */
     protected boolean isValidSymbolicDomain(String domain) {
+        if(domain.indexOf('\'') != -1) {
+            return false;
+        }
+
         String[] domainSegment = new String[10];
         boolean match = true;
         int i = 0;
Index: src/test/org/apache/commons/validator/EmailTest.java
===================================================================
RCS file:
/home/cvspublic/jakarta-commons/validator/src/test/org/apache/commons/validator/EmailTest.java,v
retrieving revision 1.27
diff -u -r1.27 EmailTest.java
--- src/test/org/apache/commons/validator/EmailTest.java	12 Jun 2004 18:18:38
-0000	1.27
+++ src/test/org/apache/commons/validator/EmailTest.java	12 Jun 2004 20:26:37 -0000
@@ -174,9 +174,13 @@
         info.setValue("andy.noble@\u008fdata-workshop.com");
         valueTest(info, false);
     
-        // The ' character is valid in an email address.
+        // The ' character is valid in an email username.
         info.setValue("andy.o'reilly@data-workshop.com");
         valueTest(info, true);
+
+        // But not in the domain name.
+        info.setValue("andy@o'reilly.data-workshop.com");
+        valueTest(info, false);
 
         info.setValue("foo+bar@i.am.not.in.us.example.com");
         valueTest(info, true);

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message