[
https://issues.apache.org/jira/browse/WW-5743?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Lukasz Lenart resolved WW-5743.
-------------------------------
Resolution: Fixed
> ActionNameSpecificityComparator can rank a broad ** pattern ahead of a
> narrower */* one
> ---------------------------------------------------------------------------------------
>
> Key: WW-5743
> URL: https://issues.apache.org/jira/browse/WW-5743
> Project: Struts 2
> Issue Type: Improvement
> Components: Plugin - Convention
> Reporter: Lukasz Lenart
> Assignee: Lukasz Lenart
> Priority: Major
> Fix For: 7.4.0
>
> Time Spent: 1h
> Remaining Estimate: 0h
>
> Follow-up to WW-3784 (7.3.0), which introduced
> {{ActionNameSpecificityComparator}} in the Convention plugin so annotated
> wildcard actions are matched most-specific-first instead of in class-scan
> order.
> The comparator's keys, in order, are: fewer wildcard tokens first, more
> literal characters first, fewer path-spanning {{\*\*}} tokens first, then
> lexical. Because the raw token count comes before the {{\*\*}} count, a
> pattern with one {{\*\*}} outranks a pattern with two {{\*}} even though
> {{\*\*}} crosses {{/}} and {{\*}} does not ({{WildcardHelper}} MATCH\_PATH vs
> MATCH\_FILE) — so {{\*\*}} is the broader pattern of the two and should lose:
> * {{a/\*\*}} — 1 wildcard token, 1 path-spanning
> * {{a/\*/\*}} — 2 wildcard tokens, 0 path-spanning
> Today the first sorts ahead of the second and shadows it for {{a/x/y}}.
> Proposed refinement: lift the {{**}}-count key above the raw token-count key
> (fewer {{\*\*}} first, then fewer tokens, then more literals). Ordering stays
> per-package by design. Worth a test pair in
> {{ActionNameSpecificityComparatorTest}} for exactly the {{a/\*\*}} vs
> {{a/\*/\*}} case, plus the {{\{var\}}} equivalent for
> {{NamedVariablePatternMatcher}} users.
> Fix version intentionally left unset.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)