This is an automated email from the ASF dual-hosted git repository.
lprimak pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/shiro.git
The following commit(s) were added to refs/heads/main by this push:
new 2140bb97f Bugfix: default case insensitive filters for programmatic
and Spring / Spring Boot configurations (#2857)
2140bb97f is described below
commit 2140bb97f73f73d5da32166c531e3b426e5f0265
Author: Lenny Primak <[email protected]>
AuthorDate: Sun Aug 16 12:45:54 2026 -0500
Bugfix: default case insensitive filters for programmatic and Spring /
Spring Boot configurations (#2857)
---
core/src/main/java/org/apache/shiro/util/AntPathMatcher.java | 9 ++++-----
.../main/java/org/apache/shiro/util/RegExPatternMatcher.java | 2 +-
.../java/org/apache/shiro/util/RegExPatternMatcherTest.java | 4 +++-
.../apache/shiro/samples/spring/config/ApplicationConfig.java | 2 +-
.../spring/web/config/AbstractShiroWebFilterConfiguration.java | 2 +-
.../apache/shiro/web/filter/mgt/DefaultFilterChainManager.java | 10 +++++-----
6 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/core/src/main/java/org/apache/shiro/util/AntPathMatcher.java
b/core/src/main/java/org/apache/shiro/util/AntPathMatcher.java
index 15bb00079..20fe93f33 100644
--- a/core/src/main/java/org/apache/shiro/util/AntPathMatcher.java
+++ b/core/src/main/java/org/apache/shiro/util/AntPathMatcher.java
@@ -69,7 +69,7 @@ public class AntPathMatcher implements PatternMatcher {
public static final String DEFAULT_PATH_SEPARATOR = "/";
private String pathSeparator = DEFAULT_PATH_SEPARATOR;
- private boolean caseInsensitive;
+ private boolean caseInsensitive = true;
/**
@@ -157,8 +157,7 @@ public class AntPathMatcher implements PatternMatcher {
if (pathIdxStart > pathIdxEnd) {
// Path is exhausted, only match if rest of pattern is * or **'s
if (pattIdxStart > pattIdxEnd) {
- return (pattern.endsWith(this.pathSeparator)
- ? path.endsWith(this.pathSeparator) :
!path.endsWith(this.pathSeparator));
+ return (pattern.endsWith(this.pathSeparator) ==
path.endsWith(this.pathSeparator));
}
if (!fullMatch) {
return true;
@@ -225,8 +224,8 @@ public class AntPathMatcher implements PatternMatcher {
strLoop:
for (int i = 0; i <= strLength - patLength; i++) {
for (int j = 0; j < patLength; j++) {
- String subPat = (String) pattDirs[pattIdxStart + j + 1];
- String subStr = (String) pathDirs[pathIdxStart + i + j];
+ String subPat = pattDirs[pattIdxStart + j + 1];
+ String subStr = pathDirs[pathIdxStart + i + j];
if (!matchStrings(subPat, subStr)) {
continue strLoop;
}
diff --git a/core/src/main/java/org/apache/shiro/util/RegExPatternMatcher.java
b/core/src/main/java/org/apache/shiro/util/RegExPatternMatcher.java
index 3109d57d9..6055d3e32 100644
--- a/core/src/main/java/org/apache/shiro/util/RegExPatternMatcher.java
+++ b/core/src/main/java/org/apache/shiro/util/RegExPatternMatcher.java
@@ -33,7 +33,7 @@ public class RegExPatternMatcher implements PatternMatcher {
private static final int CASE_INSENSITIVE = DEFAULT |
Pattern.CASE_INSENSITIVE;
- private boolean caseInsensitive;
+ private boolean caseInsensitive = true;
/**
* Simple implementation that merely uses the default pattern comparison
logic provided by the
diff --git
a/core/src/test/java/org/apache/shiro/util/RegExPatternMatcherTest.java
b/core/src/test/java/org/apache/shiro/util/RegExPatternMatcherTest.java
index 283614812..0e7168f40 100644
--- a/core/src/test/java/org/apache/shiro/util/RegExPatternMatcherTest.java
+++ b/core/src/test/java/org/apache/shiro/util/RegExPatternMatcherTest.java
@@ -65,7 +65,9 @@ public class RegExPatternMatcherTest {
}
private void assertPatternNotMatch(String pattern, String path) {
- assertPatternNotMatch(pattern, path, new RegExPatternMatcher());
+ var matcher = new RegExPatternMatcher();
+ matcher.setCaseInsensitive(false);
+ assertPatternNotMatch(pattern, path, matcher);
}
private void assertPatternNotMatch(String pattern, String path,
PatternMatcher pm) {
diff --git
a/samples/spring-mvc/src/main/java/org/apache/shiro/samples/spring/config/ApplicationConfig.java
b/samples/spring-mvc/src/main/java/org/apache/shiro/samples/spring/config/ApplicationConfig.java
index 36a71d0d0..7bf3da96a 100644
---
a/samples/spring-mvc/src/main/java/org/apache/shiro/samples/spring/config/ApplicationConfig.java
+++
b/samples/spring-mvc/src/main/java/org/apache/shiro/samples/spring/config/ApplicationConfig.java
@@ -142,7 +142,7 @@ public class ApplicationConfig {
chainDefinition.addPathDefinition("/WEB-INF/resources/login.jsp",
"anon");
//allow WebStart to pull the jars for the swing app
chainDefinition.addPathDefinition("/*.jar", "anon");
-
+ chainDefinition.addPathDefinition("/**", "anon");
return chainDefinition;
}
diff --git
a/support/spring/src/main/java/org/apache/shiro/spring/web/config/AbstractShiroWebFilterConfiguration.java
b/support/spring/src/main/java/org/apache/shiro/spring/web/config/AbstractShiroWebFilterConfiguration.java
index c525ac61d..64f6f9922 100644
---
a/support/spring/src/main/java/org/apache/shiro/spring/web/config/AbstractShiroWebFilterConfiguration.java
+++
b/support/spring/src/main/java/org/apache/shiro/spring/web/config/AbstractShiroWebFilterConfiguration.java
@@ -59,7 +59,7 @@ public class AbstractShiroWebFilterConfiguration {
@Value("#{ @environment['shiro.unauthorizedUrl'] ?: null }")
protected String unauthorizedUrl;
- @Value("#{ @environment['shiro.caseInsensitive'] ?: false }")
+ @Value("#{ @environment['shiro.caseInsensitive'] ?: true }")
protected boolean caseInsensitive;
protected List<String> globalFilters() {
diff --git
a/web/src/main/java/org/apache/shiro/web/filter/mgt/DefaultFilterChainManager.java
b/web/src/main/java/org/apache/shiro/web/filter/mgt/DefaultFilterChainManager.java
index ae679e8d4..9c32d3a9b 100644
---
a/web/src/main/java/org/apache/shiro/web/filter/mgt/DefaultFilterChainManager.java
+++
b/web/src/main/java/org/apache/shiro/web/filter/mgt/DefaultFilterChainManager.java
@@ -66,18 +66,18 @@ public class DefaultFilterChainManager implements
FilterChainManager {
*/
private Map<String, NamedFilterList> filterChains;
- private boolean caseInsensitive;
+ private boolean caseInsensitive = true;
public DefaultFilterChainManager() {
- this.filters = new LinkedHashMap<String, Filter>();
- this.filterChains = new LinkedHashMap<String, NamedFilterList>();
+ this.filters = new LinkedHashMap<>();
+ this.filterChains = new LinkedHashMap<>();
this.globalFilterNames = new ArrayList<>();
addDefaultFilters(false);
}
public DefaultFilterChainManager(FilterConfig filterConfig) {
- this.filters = new LinkedHashMap<String, Filter>();
- this.filterChains = new LinkedHashMap<String, NamedFilterList>();
+ this.filters = new LinkedHashMap<>();
+ this.filterChains = new LinkedHashMap<>();
this.globalFilterNames = new ArrayList<>();
setFilterConfig(filterConfig);
addDefaultFilters(true);