Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-2362

Client-side regular expression field validation should ensure that the entire value matches the pattern

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.4
    • Fix Version/s: 5.4
    • Component/s: tapestry-core
    • Labels:
      None

      Description

      Client and server side validation using regular expressions is inconsistent: On the client side RegExp.test is used, which returns true if the pattern is found anywhere in the string, while on the server side Matcher.matches is used, which only returns true if the entire string matches the pattern. This leads to situations where the client side validation may succeed and then fail on the server side.

      Proposed solutions:

      1. In the Regexp validator, replace matcher.matches() with matcher.find() to match the current behavior of client side validation, or
      2. Make sure that client side validation also matches the entire string

      Option 1 may have more repercussions than option 2, because using Matcher.find() may cause strings that previously failed validation to now succeed validation, unless the regex was already on the form "^pattern$". Option 1 also provides most flexibility, however, because it allows using regular expressions that match only part of the string.

        Attachments

          Activity

            People

            • Assignee:
              hlship Howard M. Lewis Ship
              Reporter:
              cnl Christian Næser Lindequist
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: