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) {
7171 }
7272
7373 public boolean matches (String address ) {
74+ // Do not match null or blank address
75+ if (!StringUtils .hasText (address )) {
76+ return false ;
77+ }
78+
7479 assertNotHostName (address );
7580 InetAddress remoteAddress = parseAddress (address );
7681 if (!this .requiredAddress .getClass ().equals (remoteAddress .getClass ())) {
Original file line number Diff line number Diff line change 11/*
2- * Copyright 2002-2019 the original author or authors.
2+ * Copyright 2002-2024 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -126,4 +126,17 @@ public void numericDomainNameThenIllegalArgumentException() {
126126 .withMessage ("ipAddress 123.156.7.18.org doesn't look like an IP Address. Is it a host name?" );
127127 }
128128
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+
129142}
You can’t perform that action at this time.
0 commit comments