File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
main/java/org/springframework/http
test/java/org/springframework/http Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 11/*
2- * Copyright 2002-2021 the original author or authors.
2+ * Copyright 2002-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.
@@ -1037,9 +1037,8 @@ public long getDate() {
10371037 */
10381038 public void setETag (@ Nullable String etag ) {
10391039 if (etag != null ) {
1040- Assert .isTrue (etag .startsWith ("\" " ) || etag .startsWith ("W/" ),
1041- "Invalid ETag: does not start with W/ or \" " );
1042- Assert .isTrue (etag .endsWith ("\" " ), "Invalid ETag: does not end with \" " );
1040+ Assert .isTrue (etag .startsWith ("\" " ) || etag .startsWith ("W/\" " ), "ETag does not start with W/\" or \" " );
1041+ Assert .isTrue (etag .endsWith ("\" " ), "ETag does not end with \" " );
10431042 set (ETAG , etag );
10441043 }
10451044 else {
Original file line number Diff line number Diff line change @@ -192,11 +192,17 @@ void ipv6Host() {
192192 }
193193
194194 @ Test
195- void illegalETag () {
195+ void illegalETagWithoutQuotes () {
196196 String eTag = "v2.6" ;
197197 assertThatIllegalArgumentException ().isThrownBy (() -> headers .setETag (eTag ));
198198 }
199199
200+ @ Test
201+ void illegalWeakETagWithoutLeadingQuote () {
202+ String etag = "W/v2.6\" " ;
203+ assertThatIllegalArgumentException ().isThrownBy (() -> headers .setETag (etag ));
204+ }
205+
200206 @ Test
201207 void ifMatch () {
202208 String ifMatch = "\" v2.6\" " ;
You can’t perform that action at this time.
0 commit comments