File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
main/java/org/springframework/security/web/firewall
test/java/org/springframework/security/web/firewall Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 11/*
2- * Copyright 2012-2021 the original author or authors.
2+ * Copyright 2012-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.
@@ -130,9 +130,13 @@ public class StrictHttpFirewall implements HttpFirewall {
130130 private static final Predicate <String > ASSIGNED_AND_NOT_ISO_CONTROL_PREDICATE = (
131131 s ) -> ASSIGNED_AND_NOT_ISO_CONTROL_PATTERN .matcher (s ).matches ();
132132
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+
133137 private Predicate <String > allowedHeaderNames = ASSIGNED_AND_NOT_ISO_CONTROL_PREDICATE ;
134138
135- private Predicate <String > allowedHeaderValues = ASSIGNED_AND_NOT_ISO_CONTROL_PREDICATE ;
139+ private Predicate <String > allowedHeaderValues = HEADER_VALUE_PREDICATE ;
136140
137141 private Predicate <String > allowedParameterNames = ASSIGNED_AND_NOT_ISO_CONTROL_PREDICATE ;
138142
Original file line number Diff line number Diff line change 11/*
2- * Copyright 2012-2021 the original author or authors.
2+ * Copyright 2012-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.
@@ -781,6 +781,13 @@ public void getFirewalledRequestGetHeaderWhenControlCharacterInHeaderValueThenEx
781781 assertThatExceptionOfType (RequestRejectedException .class ).isThrownBy (() -> request .getHeader ("Something" ));
782782 }
783783
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+
784791 @ Test
785792 public void getFirewalledRequestGetHeaderWhenUndefinedCharacterInHeaderValueThenException () {
786793 this .request .addHeader ("Something" , "bad\uFFFE value" );
You can’t perform that action at this time.
0 commit comments