Commons Validator
  1. Commons Validator
  2. VALIDATOR-85

EmailValidator - valid email address fails

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Nightly Builds
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

      Description

      I just downloaded the head version (1.10) of <I>EmailValidator.java</I> from
      http://cvs.apache.org/...

      1. For a valid email address with symbolic name like <B>someone@yahoo.com<B>,
      the output from isValid() method always returns <B>FALSE</B>.

      2. For an email address with IP address like <B>someone@216.109.118.76<B>, the
      ouput from isValid() method always returns <B>FALSE</B>.

      NB: 216.109.118.76 is one of yahoo's mirror ip address.

      When I looked at the code, I figured out the following points:
      1. In the method isValidSymbolicDomain(), the matcher uses ATOM_PATTERN instead
      of DOMAIN_PATTERN. For eg, <B>yahoo.com</B> is a valid DOMAIN_PATTERN but not a
      valid ATOM_PATTERN as per the regular expressions used for those strings.

      2. In the method isValidDomain(), the check for <B>symbolic</B> variable should
      be inside the "else block" as symbolic will always be "false" for domains that
      matches IP_DOMAIN_PATTERN.

      After modifying the code in the above two places, isValid() method returns true
      for the above metioned email addresses.

      Thanks
      Srirajesh

        Activity

        Hide
        Danny Angus added a comment -

        someone@216.109.118.76

        is NOT a valid email address the ip address should be encolsed in [] as in
        someone@[216.109.118.76]
        Therefore the observed behaviour of case 2 correct and it is Not A Bug.

        Show
        Danny Angus added a comment - someone@216.109.118.76 is NOT a valid email address the ip address should be encolsed in [] as in someone@ [216.109.118.76] Therefore the observed behaviour of case 2 correct and it is Not A Bug.
        Hide
        Srirajesh added a comment -

        If <B>someone@[216.109.118.76]</B> is a valid email address, then even for
        this, the output is "false" bcos in the code, the pattern that matches the
        domain is "^(
        d

        {1,3})[.](
        d{1,3}

        )[.](
        d

        {1,3})[.](
        d{1,3}

        )$" where it says
        that the domain can only have digits and not "[" or "]" in the email addresss.
        So it again boils down to a BUG.

        Thanks
        Srirajesh

        Show
        Srirajesh added a comment - If <B>someone@ [216.109.118.76] </B> is a valid email address, then even for this, the output is "false" bcos in the code, the pattern that matches the domain is "^( d {1,3}) [.] ( d{1,3} ) [.] ( d {1,3}) [.] ( d{1,3} )$" where it says that the domain can only have digits and not " [" or "] " in the email addresss. So it again boils down to a BUG . Thanks Srirajesh
        Hide
        Ted Husted added a comment -

        Srirajesh,

        If you've successfully modified the code, then we would appreciate your
        donating the patch back to the project. This is a volunteer project and we
        depend on contributions from developers, like you.

        -Ted.

        Show
        Ted Husted added a comment - Srirajesh, If you've successfully modified the code, then we would appreciate your donating the patch back to the project. This is a volunteer project and we depend on contributions from developers, like you. -Ted.
        Hide
        Don Brown added a comment -

        Created an attachment (id=11781)
        Diffs of main class and unit tests

        Show
        Don Brown added a comment - Created an attachment (id=11781) Diffs of main class and unit tests
        Hide
        Don Brown added a comment -

        I couldn't replicate the first bug, but I could the second one. I added a unit
        test to ensure it stays fixed. Also, I started going through the standard email
        validation tests that are apparently disabled, and fixed the first few but it
        seems there is a lot of work still to be done. Isn't there a perl script
        somewhere that will validate email addresses correctly?

        Show
        Don Brown added a comment - I couldn't replicate the first bug, but I could the second one. I added a unit test to ensure it stays fixed. Also, I started going through the standard email validation tests that are apparently disabled, and fixed the first few but it seems there is a lot of work still to be done. Isn't there a perl script somewhere that will validate email addresses correctly?
        Hide
        Ted Husted added a comment -

        Marking this fixed as to the second case. If a clarifications for the first
        case materializes, we can can reopen.

        Don, I ran into character set issues with the second test in your patch, so
        left it off for now.

        Show
        Ted Husted added a comment - Marking this fixed as to the second case. If a clarifications for the first case materializes, we can can reopen. Don, I ran into character set issues with the second test in your patch, so left it off for now.

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development