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 {
50
50
* come.
51
51
*/
52
52
public IpAddressMatcher (String ipAddress ) {
53
+ Assert .hasText (ipAddress , "ipAddress cannot be empty" );
53
54
assertNotHostName (ipAddress );
54
55
if (ipAddress .indexOf ('/' ) > 0 ) {
55
56
String [] addressAndMask = StringUtils .split (ipAddress , "/" );
Original file line number Diff line number Diff line change @@ -139,4 +139,18 @@ public void matchesWhenAddressIsNullThenFalse() {
139
139
assertThat (this .v4matcher .matches ((String ) null )).isFalse ();
140
140
}
141
141
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
+
142
156
}
You can’t perform that action at this time.
0 commit comments