Browse Source

Fix exception in AntPathMatcher for leading *

Issue: SPR-13139
pull/819/merge
Martin Lippert 11 years ago committed by Rossen Stoyanchev
parent
commit
63f01c851f
  1. 2
      spring-core/src/main/java/org/springframework/util/AntPathMatcher.java
  2. 4
      spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java

2
spring-core/src/main/java/org/springframework/util/AntPathMatcher.java

@ -747,7 +747,7 @@ public class AntPathMatcher implements PathMatcher { @@ -747,7 +747,7 @@ public class AntPathMatcher implements PathMatcher {
this.doubleWildcards++;
pos += 2;
}
else if (!this.pattern.substring(pos - 1).equals(".*")) {
else if (pos > 0 && !this.pattern.substring(pos - 1).equals(".*")) {
this.singleWildcards++;
pos++;
}

4
spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java

@ -479,6 +479,10 @@ public class AntPathMatcherTests { @@ -479,6 +479,10 @@ public class AntPathMatcherTests {
// longer is better
assertEquals(1, comparator.compare("/hotels", "/hotels2"));
//SPR-13139
assertEquals(-1, comparator.compare("*", "*/**"));
assertEquals(1, comparator.compare("*/**", "*"));
}
@Test

Loading…
Cancel
Save