File tree Expand file tree Collapse file tree 2 files changed +15
-0
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 +15
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ public final class IpAddressMatcher implements RequestMatcher {
5050 * come.
5151 */
5252 public IpAddressMatcher (String ipAddress ) {
53+ Assert .hasText (ipAddress , "ipAddress cannot be empty" );
5354 assertNotHostName (ipAddress );
5455 if (ipAddress .indexOf ('/' ) > 0 ) {
5556 String [] addressAndMask = StringUtils .split (ipAddress , "/" );
Original file line number Diff line number Diff line change @@ -139,4 +139,18 @@ public void matchesWhenAddressIsNullThenFalse() {
139139 assertThat (this .v4matcher .matches ((String ) null )).isFalse ();
140140 }
141141
142+ // gh-15527
143+ @ Test
144+ public void constructorWhenRequiredAddressIsNullThenThrowsIllegalArgumentException () {
145+ assertThatIllegalArgumentException ().isThrownBy (() -> new IpAddressMatcher (null ))
146+ .withMessage ("ipAddress cannot be empty" );
147+ }
148+
149+ // gh-15527
150+ @ Test
151+ public void constructorWhenRequiredAddressIsEmptyThenThrowsIllegalArgumentException () {
152+ assertThatIllegalArgumentException ().isThrownBy (() -> new IpAddressMatcher ("" ))
153+ .withMessage ("ipAddress cannot be empty" );
154+ }
155+
142156}
You can’t perform that action at this time.
0 commit comments