You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Lukasz Lenart (Jira)" <ji...@apache.org> on 2023/05/16 18:46:00 UTC

[jira] [Commented] (WW-5309) NamedVariablePatternMatcher throws when pattern begins with a variable

    [ https://issues.apache.org/jira/browse/WW-5309?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17723255#comment-17723255 ] 

Lukasz Lenart commented on WW-5309:
-----------------------------------

[~chylek-qr] could you review this PR https://github.com/apache/struts/pull/686?

> 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.1, 6.1.2
>            Reporter: chylek
>            Priority: Minor
>             Fix For: 6.2.0
>
>
> 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)