From f786feb5e1183177e97935f7be2603b94597c4b3 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Tue, 10 Jan 2017 17:24:47 -0800 Subject: [PATCH] Ensure correct recognition for start of match-the-rest path elements Without this change the /{*foobar} and /** path elements were not correctly enforcing that the first character they encounter must be a separator. This problem was introduced when adjusting the generated path element chains for these constructs. Originally the generated chain included a SeparatorPathElement but in order for these to match 'nothing' (i.e. /foo matches /foo/{*foobar}) the separator path element was removed, so the separator enforcement needed moving into the CaptureTheRestPathElement and WildcardTheRestPathElement. Issue: SPR-14544 --- .../web/util/patterns/CaptureTheRestPathElement.java | 6 ++++++ .../web/util/patterns/WildcardTheRestPathElement.java | 5 +++++ .../web/util/patterns/PathPatternMatcherTests.java | 10 ++++++++++ 3 files changed, 21 insertions(+) diff --git a/spring-web/src/main/java/org/springframework/web/util/patterns/CaptureTheRestPathElement.java b/spring-web/src/main/java/org/springframework/web/util/patterns/CaptureTheRestPathElement.java index ff2076abb8..659b28e74f 100644 --- a/spring-web/src/main/java/org/springframework/web/util/patterns/CaptureTheRestPathElement.java +++ b/spring-web/src/main/java/org/springframework/web/util/patterns/CaptureTheRestPathElement.java @@ -45,6 +45,12 @@ class CaptureTheRestPathElement extends PathElement { // No need to handle 'match start' checking as this captures everything // anyway and cannot be followed by anything else // assert next == null + + // If there is more data, it must start with the separator + if (candidateIndex