diff options
author | ToBinio <81473300+ToBinio@users.noreply.github.com> | 2024-08-08 16:33:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-08 14:33:54 +0000 |
commit | 8fab6911d16577bf98f5179dab7e0d75e57bc5ba (patch) | |
tree | 18e38ba74d90ac73c2c9bbd46b19b3911a00d19b /components/script | |
parent | b8cf0cf9afa03d5e2ba3f8a4727e4de00ab63eb2 (diff) | |
download | servo-8fab6911d16577bf98f5179dab7e0d75e57bc5ba.tar.gz servo-8fab6911d16577bf98f5179dab7e0d75e57bc5ba.zip |
script: dont unwrap in header set (#32973)
Signed-off-by: tobinio <tobias.frischmann1@gmail.com>
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/headers.rs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/components/script/dom/headers.rs b/components/script/dom/headers.rs index 1d1d98ac615..7d18913533c 100644 --- a/components/script/dom/headers.rs +++ b/components/script/dom/headers.rs @@ -214,10 +214,20 @@ impl HeadersMethods for Headers { } // Step 7 // https://fetch.spec.whatwg.org/#concept-header-list-set - self.header_list.borrow_mut().insert( - HeaderName::from_str(&valid_name).unwrap(), - HeaderValue::from_bytes(&valid_value).unwrap(), - ); + match HeaderValue::from_bytes(&valid_value) { + Ok(value) => { + self.header_list + .borrow_mut() + .insert(HeaderName::from_str(&valid_name).unwrap(), value); + }, + Err(_) => { + // can't add the header, but we don't need to panic the browser over it + warn!( + "Servo thinks \"{:?}\" is a valid HTTP header value but HeaderValue doesn't.", + valid_value + ); + }, + }; Ok(()) } } |