From b92d249f450920e48e640af6bbd0bd509e7d707d Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 12 Nov 2020 22:00:47 +0000 Subject: [PATCH] AntPathMatcher allows newline in URI template variables Closes gh-23252 --- .../src/main/java/org/springframework/util/AntPathMatcher.java | 2 +- .../test/java/org/springframework/util/AntPathMatcherTests.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java b/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java index e1e06b4719..59087313ea 100644 --- a/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java +++ b/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java @@ -644,7 +644,7 @@ public class AntPathMatcher implements PathMatcher { private static final Pattern GLOB_PATTERN = Pattern.compile("\\?|\\*|\\{((?:\\{[^/]+?}|[^/{}]|\\\\[{}])+?)}"); - private static final String DEFAULT_VARIABLE_PATTERN = "(.*)"; + private static final String DEFAULT_VARIABLE_PATTERN = "((?s).*)"; private final String rawPattern; diff --git a/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java b/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java index c85550838d..8bebf5920f 100644 --- a/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java +++ b/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java @@ -130,6 +130,7 @@ class AntPathMatcherTests { assertThat(pathMatcher.match("", "")).isTrue(); assertThat(pathMatcher.match("/{bla}.*", "/testing.html")).isTrue(); + assertThat(pathMatcher.match("/{bla}", "//x\ny")).isTrue(); } @Test