Fix incorrect weak ETag assertion
See gh-33374
This commit is contained in:
@@ -1048,8 +1048,8 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
*/
|
||||
public void setETag(@Nullable String etag) {
|
||||
if (etag != null) {
|
||||
Assert.isTrue(etag.startsWith("\"") || etag.startsWith("W/"),
|
||||
"Invalid ETag: does not start with W/ or \"");
|
||||
Assert.isTrue(etag.startsWith("\"") || etag.startsWith("W/\""),
|
||||
"Invalid ETag: does not start with W/\" or \"");
|
||||
Assert.isTrue(etag.endsWith("\""), "Invalid ETag: does not end with \"");
|
||||
set(ETAG, etag);
|
||||
}
|
||||
|
||||
@@ -196,6 +196,12 @@ class HttpHeadersTests {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> headers.setETag(eTag));
|
||||
}
|
||||
|
||||
@Test
|
||||
void illegalETagWithoutQuoteAfterWSlash() {
|
||||
String etag = "W/v2.6\"";
|
||||
assertThatIllegalArgumentException().as("Invalid Weak ETag").isThrownBy(() -> headers.setETag(etag));
|
||||
}
|
||||
|
||||
@Test
|
||||
void ifMatch() {
|
||||
String ifMatch = "\"v2.6\"";
|
||||
|
||||
Reference in New Issue
Block a user