File tree 2 files changed +10
-5
lines changed
main/java/org/springframework/http
test/java/org/springframework/http
2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2023 the original author or authors.
2
+ * Copyright 2002-2024 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -1044,9 +1044,8 @@ public long getDate() {
1044
1044
*/
1045
1045
public void setETag (@ Nullable String etag ) {
1046
1046
if (etag != null ) {
1047
- Assert .isTrue (etag .startsWith ("\" " ) || etag .startsWith ("W/" ),
1048
- "Invalid ETag: does not start with W/ or \" " );
1049
- Assert .isTrue (etag .endsWith ("\" " ), "Invalid ETag: does not end with \" " );
1047
+ Assert .isTrue (etag .startsWith ("\" " ) || etag .startsWith ("W/\" " ), "ETag does not start with W/\" or \" " );
1048
+ Assert .isTrue (etag .endsWith ("\" " ), "ETag does not end with \" " );
1050
1049
set (ETAG , etag );
1051
1050
}
1052
1051
else {
Original file line number Diff line number Diff line change @@ -192,11 +192,17 @@ void ipv6Host() {
192
192
}
193
193
194
194
@ Test
195
- void illegalETag () {
195
+ void illegalETagWithoutQuotes () {
196
196
String eTag = "v2.6" ;
197
197
assertThatIllegalArgumentException ().isThrownBy (() -> headers .setETag (eTag ));
198
198
}
199
199
200
+ @ Test
201
+ void illegalWeakETagWithoutLeadingQuote () {
202
+ String etag = "W/v2.6\" " ;
203
+ assertThatIllegalArgumentException ().isThrownBy (() -> headers .setETag (etag ));
204
+ }
205
+
200
206
@ Test
201
207
void ifMatch () {
202
208
String ifMatch = "\" v2.6\" " ;
You can’t perform that action at this time.
0 commit comments