We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 89bcc45 commit 0f26be1Copy full SHA for 0f26be1
src/conditional/etag.rs
@@ -84,6 +84,16 @@ impl ETag {
84
}
85
};
86
87
+ if !s
88
+ .bytes()
89
+ .all(|c| c == 0x21 || (c >= 0x23 && c <= 0x7E) || c >= 0x80)
90
+ {
91
+ return Err(Error::from_str(
92
+ StatusCode::BadRequest,
93
+ "Invalid ETag header",
94
+ ));
95
+ }
96
+
97
let etag = if weak { Self::Weak(s) } else { Self::Strong(s) };
98
Ok(Some(etag))
99
@@ -180,4 +190,11 @@ mod test {
180
190
let err = ETag::from_headers(headers).unwrap_err();
181
191
assert_eq!(format!("{}", err), msg);
182
192
193
194
+ #[test]
195
+ fn validate_characters() -> crate::Result<()> {
196
+ assert_entry_err(r#"""hello""#, "Invalid ETag header");
197
+ assert_entry_err("\"hello\x7F\"", "Invalid ETag header");
198
+ Ok(())
199
183
200
0 commit comments