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

NamedVariablePatternMatcher throws when pattern begins with a variable

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 6.1.1, 6.1.2
    • 6.2.0
    • Other
    • None

    Description

      Hello!

      We found a regression in NamedVariablePatternMatcher that we believe was introduced by the fix to WW-3529.

      If the pattern begins with a variable, for example {urlLocale}/eula_cz, it throws an exception Missing openning '{' in [\{urlLocale}/eula_cz]! due to this condition: https://github.com/apache/struts/blob/master/core/src/main/java/com/opensymphony/xwork2/util/NamedVariablePatternMatcher.java#L90-L92

      In the first iteration, the loop reads the variable {urlLocale}. In the next iteration, it finds no more opening braces, but then it throws an exception when data.indexOf('}') > -1 - which is always true when the pattern contains any variables, so it always throws an exception.

      Replacing the faulty condition with data.indexOf('}', s) > -1 should fix the issue.

      It's also relatively easy to work around by extending NamedVariablePatternMatcher, copying the compilePattern method, and applying the fix there, so it's not blocking us from updating Struts.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              chylek-qr chylek
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: