File tree 2 files changed +14
-3
lines changed
main/java/org/springframework/security/web/firewall
test/java/org/springframework/security/web/firewall
2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2012-2023 the original author or authors.
2
+ * Copyright 2012-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.
@@ -130,9 +130,13 @@ public class StrictHttpFirewall implements HttpFirewall {
130
130
private static final Predicate <String > ASSIGNED_AND_NOT_ISO_CONTROL_PREDICATE = (
131
131
s ) -> ASSIGNED_AND_NOT_ISO_CONTROL_PATTERN .matcher (s ).matches ();
132
132
133
+ private static final Pattern HEADER_VALUE_PATTERN = Pattern .compile ("[\\ p{IsAssigned}&&[[^\\ p{IsControl}]||\\ t]]*" );
134
+
135
+ private static final Predicate <String > HEADER_VALUE_PREDICATE = (s ) -> HEADER_VALUE_PATTERN .matcher (s ).matches ();
136
+
133
137
private Predicate <String > allowedHeaderNames = ASSIGNED_AND_NOT_ISO_CONTROL_PREDICATE ;
134
138
135
- private Predicate <String > allowedHeaderValues = ASSIGNED_AND_NOT_ISO_CONTROL_PREDICATE ;
139
+ private Predicate <String > allowedHeaderValues = HEADER_VALUE_PREDICATE ;
136
140
137
141
private Predicate <String > allowedParameterNames = ASSIGNED_AND_NOT_ISO_CONTROL_PREDICATE ;
138
142
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2012-2021 the original author or authors.
2
+ * Copyright 2012-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.
@@ -781,6 +781,13 @@ public void getFirewalledRequestGetHeaderWhenControlCharacterInHeaderValueThenEx
781
781
assertThatExceptionOfType (RequestRejectedException .class ).isThrownBy (() -> request .getHeader ("Something" ));
782
782
}
783
783
784
+ @ Test
785
+ public void getFirewalledRequestGetHeaderWhenHorizontalTabInHeaderValueThenNoException () {
786
+ this .request .addHeader ("Something" , "tab\t value" );
787
+ HttpServletRequest request = this .firewall .getFirewalledRequest (this .request );
788
+ assertThat (request .getHeader ("Something" )).isEqualTo ("tab\t value" );
789
+ }
790
+
784
791
@ Test
785
792
public void getFirewalledRequestGetHeaderWhenUndefinedCharacterInHeaderValueThenException () {
786
793
this .request .addHeader ("Something" , "bad\uFFFE value" );
You can’t perform that action at this time.
0 commit comments