File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
main/java/org/springframework/security/web/util/matcher
test/java/org/springframework/security/web/util/matcher Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,11 @@ public boolean matches(HttpServletRequest request) {
71
71
}
72
72
73
73
public boolean matches (String address ) {
74
+ // Do not match null or blank address
75
+ if (!StringUtils .hasText (address )) {
76
+ return false ;
77
+ }
78
+
74
79
assertNotHostName (address );
75
80
InetAddress remoteAddress = parseAddress (address );
76
81
if (!this .requiredAddress .getClass ().equals (remoteAddress .getClass ())) {
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2019 the original author or authors.
2
+ * Copyright 2002-2024 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -126,4 +126,17 @@ public void numericDomainNameThenIllegalArgumentException() {
126
126
.withMessage ("ipAddress 123.156.7.18.org doesn't look like an IP Address. Is it a host name?" );
127
127
}
128
128
129
+ // gh-15527
130
+ @ Test
131
+ public void matchesWhenIpAddressIsLoopbackAndAddressIsNullThenFalse () {
132
+ IpAddressMatcher ipAddressMatcher = new IpAddressMatcher ("127.0.0.1" );
133
+ assertThat (ipAddressMatcher .matches ((String ) null )).isFalse ();
134
+ }
135
+
136
+ // gh-15527
137
+ @ Test
138
+ public void matchesWhenAddressIsNullThenFalse () {
139
+ assertThat (this .v4matcher .matches ((String ) null )).isFalse ();
140
+ }
141
+
129
142
}
You can’t perform that action at this time.
0 commit comments