Uploaded image for project: 'Commons Validator'
  1. Commons Validator
  2. VALIDATOR-101

[validator] EmailValidator allows apostrophes in domain name

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.1.0 (alpha)
    • None
    • None
    • None
    • Operating System: All
      Platform: All

    • 29541

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

      Attachments

        Activity

          People

            Unassigned Unassigned
            mcraig@visiblepath.com Micah Craig
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: