Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-3885

Invalid email address validation (client side). EmailValidator regex implementation doesn't match documentation.

    XMLWordPrintableJSON

Details

    • Important

    Description

      EmailValidator documentation specifies following regular expression to validate email addresses:

      \\b(^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@([A-Za-z0-9-])+((\\.com)|(\\.net)|(\\.org)|(\\.info)|(\\.edu)|(\\.mil)|(\\.gov)|(\\.biz)|(\\.ws)|(\\.us)|(\\.tv)|(\\.cc)|(\\.aero)|(\\.arpa)|(\\.coop)|(\\.int)|(\\.jobs)|(\\.museum)|(\\.name)|(\\.pro)|(\\.travel)|(\\.nato)|(\\..{2,3})|(\\..{2,3}\\..{2,3}))$)\\b
      

      but the actual implementation uses following regular expression:

      \\b(^['_A-Za-z0-9-]+(\\.['_A-Za-z0-9-]+)*@([A-Za-z0-9-])+(\\.[A-Za-z0-9-]+)*((\\.[A-Za-z0-9]{2,})|(\\.[A-Za-z0-9]{2,}\\.[A-Za-z0-9]{2,}))$)\\b
      

      which is wrong, because this email address "aaa@aa.aaaaaaa" is being validated as a correct email address (I experience this issue in client side validation).

      The (more?) correct regular expression should be probably the one specified in the documentation, but care needs to be taken of the apostrophe for the front part of the email address as well. The resulting regular expression might be something like this:

      \\b(^['_A-Za-z0-9-]+(\\.['_A-Za-z0-9-]+)*@([A-Za-z0-9-])+((\\.com)|(\\.net)|(\\.org)|(\\.info)|(\\.edu)|(\\.mil)|(\\.gov)|(\\.biz)|(\\.ws)|(\\.us)|(\\.tv)|(\\.cc)|(\\.aero)|(\\.arpa)|(\\.coop)|(\\.int)|(\\.jobs)|(\\.museum)|(\\.name)|(\\.pro)|(\\.travel)|(\\.nato)|(\\..{2,3})|(\\..{2,3}\\..{2,3}))$)\\b
      

      Attachments

        1. WW-3885-struts2-core.patch
          1 kB
          Martin Uhlir
        2. WW-3885-xwork-core.patch
          3 kB
          Martin Uhlir

        Issue Links

          Activity

            People

              lukaszlenart Lukasz Lenart
              stoupa91 Martin Uhlir
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 1h
                  1h
                  Remaining:
                  Remaining Estimate - 1h
                  1h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified