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
This commit is contained in:
Andy Clement
2017-01-10 17:24:47 -08:00
committed by Brian Clozel
parent f58ffad939
commit f786feb5e1
3 changed files with 21 additions and 0 deletions

View File

@@ -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<matchingContext.candidateLength &&
matchingContext.candidate[candidateIndex] != separator) {
return false;
}
while ((candidateIndex+1)<matchingContext.candidateLength &&
matchingContext.candidate[candidateIndex+1] == separator) {
candidateIndex++;

View File

@@ -34,6 +34,11 @@ class WildcardTheRestPathElement extends PathElement {
@Override
public boolean matches(int candidateIndex, MatchingContext matchingContext) {
// If there is more data, it must start with the separator
if (candidateIndex < matchingContext.candidateLength &&
matchingContext.candidate[candidateIndex] != separator) {
return false;
}
return true;
}