chylek created WW-5309:
--------------------------
Summary: NamedVariablePatternMatcher throws when pattern begins
with a variable
Key: WW-5309
URL: https://issues.apache.org/jira/browse/WW-5309
Project: Struts 2
Issue Type: Bug
Components: Other
Affects Versions: 6.1.2, 6.1.1
Reporter: chylek
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.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)