Skip to content

Commit 5fee796

Browse files
committed
Merge branch '6.1.x'
2 parents cef1b7e + fe4fd00 commit 5fee796

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

spring-web/src/main/java/org/springframework/http/HttpHeaders.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -1073,9 +1073,8 @@ public long getDate() {
10731073
*/
10741074
public void setETag(@Nullable String etag) {
10751075
if (etag != null) {
1076-
Assert.isTrue(etag.startsWith("\"") || etag.startsWith("W/"),
1077-
"Invalid ETag: does not start with W/ or \"");
1078-
Assert.isTrue(etag.endsWith("\""), "Invalid ETag: does not end with \"");
1076+
Assert.isTrue(etag.startsWith("\"") || etag.startsWith("W/\""), "ETag does not start with W/\" or \"");
1077+
Assert.isTrue(etag.endsWith("\""), "ETag does not end with \"");
10791078
set(ETAG, etag);
10801079
}
10811080
else {

spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,17 @@ void ipv6Host() {
214214
}
215215

216216
@Test
217-
void illegalETag() {
217+
void illegalETagWithoutQuotes() {
218218
String eTag = "v2.6";
219219
assertThatIllegalArgumentException().isThrownBy(() -> headers.setETag(eTag));
220220
}
221221

222+
@Test
223+
void illegalWeakETagWithoutLeadingQuote() {
224+
String etag = "W/v2.6\"";
225+
assertThatIllegalArgumentException().isThrownBy(() -> headers.setETag(etag));
226+
}
227+
222228
@Test
223229
void ifMatch() {
224230
String ifMatch = "\"v2.6\"";

0 commit comments

Comments
 (0)