Skip to content

Commit

Permalink
Fix incorrect weak ETag assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
kashike authored and rstoyanchev committed Aug 13, 2024
1 parent 1911ca7 commit 1703b71
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1048,8 +1048,8 @@ public long getDate() {
*/
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ void illegalETag() {
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\"";
Expand Down

0 comments on commit 1703b71

Please sign in to comment.