Commons Validator
  1. Commons Validator
  2. VALIDATOR-101

[validator] EmailValidator allows apostrophes in domain name

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.0 (alpha)
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

      Description

      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);

        Activity

        Hide
        Micah Craig added a comment -

        Created an attachment (id=11836)
        reject apostrophes in domain names

        Show
        Micah Craig added a comment - Created an attachment (id=11836) reject apostrophes in domain names
        Hide
        Ralf Hauser added a comment -

        see also COM-1647 and COM-1889

        Show
        Ralf Hauser added a comment - see also COM-1647 and COM-1889
        Hide
        Don Brown added a comment -

        Fixed in changeset [232623] Thanks for the patch!

        Show
        Don Brown added a comment - Fixed in changeset [232623] Thanks for the patch!

          People

          • Assignee:
            Unassigned
            Reporter:
            Micah Craig
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development