Skip to content

Commit eaaa813

Browse files
committed
Fix header value typo
Closes gh-11948
1 parent 10b3a9b commit eaaa813

File tree

8 files changed

+13
-13
lines changed

8 files changed

+13
-13
lines changed

Diff for: config/src/main/java/org/springframework/security/config/annotation/web/configurers/HeadersConfigurer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ public XXssConfig xssProtectionEnabled(boolean enabled) {
801801
* replaced with "#". For example:
802802
*
803803
* <pre>
804-
* X-XSS-Protection: 1 ; mode=block
804+
* X-XSS-Protection: 1; mode=block
805805
* </pre>
806806
* @param headerValue the new header value
807807
* @since 5.8

Diff for: config/src/test/java/org/springframework/security/config/web/server/HeaderSpecTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void setup() {
7575
this.expectedHeaders.add(HttpHeaders.EXPIRES, "0");
7676
this.expectedHeaders.add(ContentTypeOptionsServerHttpHeadersWriter.X_CONTENT_OPTIONS, "nosniff");
7777
this.expectedHeaders.add(XFrameOptionsServerHttpHeadersWriter.X_FRAME_OPTIONS, "DENY");
78-
this.expectedHeaders.add(XXssProtectionServerHttpHeadersWriter.X_XSS_PROTECTION, "1 ; mode=block");
78+
this.expectedHeaders.add(XXssProtectionServerHttpHeadersWriter.X_XSS_PROTECTION, "1; mode=block");
7979
}
8080

8181
@Test
@@ -320,7 +320,7 @@ public void headersWhenXssProtectionValueEnabledThenXssProtectionWritten() {
320320

321321
@Test
322322
public void headersWhenXssProtectionValueEnabledModeBlockThenXssProtectionWritten() {
323-
this.expectedHeaders.set(XXssProtectionServerHttpHeadersWriter.X_XSS_PROTECTION, "1 ; mode=block");
323+
this.expectedHeaders.set(XXssProtectionServerHttpHeadersWriter.X_XSS_PROTECTION, "1; mode=block");
324324
// @formatter:off
325325
this.http.headers()
326326
.xssProtection()

Diff for: config/src/test/kotlin/org/springframework/security/config/web/server/ServerHeadersDslTests.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class ServerHeadersDslTests {
7070
.expectHeader().valueEquals(HttpHeaders.CACHE_CONTROL, "no-cache, no-store, max-age=0, must-revalidate")
7171
.expectHeader().valueEquals(HttpHeaders.EXPIRES, "0")
7272
.expectHeader().valueEquals(HttpHeaders.PRAGMA, "no-cache")
73-
.expectHeader().valueEquals(XXssProtectionServerHttpHeadersWriter.X_XSS_PROTECTION, "1 ; mode=block")
73+
.expectHeader().valueEquals(XXssProtectionServerHttpHeadersWriter.X_XSS_PROTECTION, "1; mode=block")
7474
}
7575

7676
@EnableWebFluxSecurity

Diff for: config/src/test/kotlin/org/springframework/security/config/web/server/ServerHttpSecurityDslTests.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class ServerHttpSecurityDslTests {
123123
.expectHeader().valueEquals(HttpHeaders.CACHE_CONTROL, "no-cache, no-store, max-age=0, must-revalidate")
124124
.expectHeader().valueEquals(HttpHeaders.EXPIRES, "0")
125125
.expectHeader().valueEquals(HttpHeaders.PRAGMA, "no-cache")
126-
.expectHeader().valueEquals(XXssProtectionServerHttpHeadersWriter.X_XSS_PROTECTION, "1 ; mode=block")
126+
.expectHeader().valueEquals(XXssProtectionServerHttpHeadersWriter.X_XSS_PROTECTION, "1; mode=block")
127127
}
128128

129129
@EnableWebFluxSecurity

Diff for: config/src/test/kotlin/org/springframework/security/config/web/server/ServerXssProtectionDslTests.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class ServerXssProtectionDslTests {
5656
this.client.get()
5757
.uri("/")
5858
.exchange()
59-
.expectHeader().valueEquals(XXssProtectionServerHttpHeadersWriter.X_XSS_PROTECTION, "1 ; mode=block")
59+
.expectHeader().valueEquals(XXssProtectionServerHttpHeadersWriter.X_XSS_PROTECTION, "1; mode=block")
6060
}
6161

6262
@EnableWebFluxSecurity

Diff for: web/src/main/java/org/springframework/security/web/header/writers/XXssProtectionHeaderWriter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public void setBlock(boolean block) {
122122
* specify mode as blocked. The content will be replaced with "#". For example:
123123
*
124124
* <pre>
125-
* X-XSS-Protection: 1 ; mode=block
125+
* X-XSS-Protection: 1; mode=block
126126
* </pre>
127127
* @param headerValue the new header value
128128
* @throws IllegalArgumentException when headerValue is null
@@ -134,7 +134,7 @@ public void setHeaderValue(HeaderValue headerValue) {
134134
}
135135

136136
/**
137-
* The value of the x-xss-protection header. One of: "0", "1", "1 ; mode=block"
137+
* The value of the x-xss-protection header. One of: "0", "1", "1; mode=block"
138138
*
139139
* @author Daniel Garnier-Moiroux
140140
* @since 5.8

Diff for: web/src/main/java/org/springframework/security/web/server/header/XXssProtectionServerHttpHeadersWriter.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public void setBlock(boolean block) {
122122
* specify mode as blocked. The content will be replaced with "#". For example:
123123
*
124124
* <pre>
125-
* X-XSS-Protection: 1 ; mode=block
125+
* X-XSS-Protection: 1; mode=block
126126
* </pre>
127127
* @param headerValue the new headerValue
128128
* @throws IllegalArgumentException if headerValue is null
@@ -135,14 +135,14 @@ public void setHeaderValue(HeaderValue headerValue) {
135135
}
136136

137137
/**
138-
* The value of the x-xss-protection header. One of: "0", "1", "1 ; mode=block"
138+
* The value of the x-xss-protection header. One of: "0", "1", "1; mode=block"
139139
*
140140
* @author Daniel Garnier-Moiroux
141141
* @since 5.8
142142
*/
143143
public enum HeaderValue {
144144

145-
DISABLED("0"), ENABLED("1"), ENABLED_MODE_BLOCK("1 ; mode=block");
145+
DISABLED("0"), ENABLED("1"), ENABLED_MODE_BLOCK("1; mode=block");
146146

147147
private final String value;
148148

Diff for: web/src/test/java/org/springframework/security/web/server/header/XXssProtectionServerHttpHeadersWriterTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void writeHeadersWhenNoHeadersThenWriteHeaders() {
4949
this.writer.writeHttpHeaders(this.exchange);
5050
assertThat(this.headers).hasSize(1);
5151
assertThat(this.headers.get(XXssProtectionServerHttpHeadersWriter.X_XSS_PROTECTION))
52-
.containsOnly("1 ; mode=block");
52+
.containsOnly("1; mode=block");
5353
}
5454

5555
@Test
@@ -99,7 +99,7 @@ void writeHeadersWhenEnabledModeBlockThenWriteHeaders() {
9999
this.writer.writeHttpHeaders(this.exchange);
100100
assertThat(this.headers).hasSize(1);
101101
assertThat(this.headers.get(XXssProtectionServerHttpHeadersWriter.X_XSS_PROTECTION))
102-
.containsOnly("1 ; mode=block");
102+
.containsOnly("1; mode=block");
103103
}
104104

105105
}

0 commit comments

Comments
 (0)