mirror of
https://github.com/servo/servo.git
synced 2025-06-11 10:00:18 +00:00
Fix module script MIME check to not include params
Also makes it error when there is no MIME type available.
This commit is contained in:
parent
be917ae9ef
commit
508bfbd0da
1 changed files with 11 additions and 2 deletions
|
@ -931,9 +931,18 @@ impl FetchResponseListener for ModuleContext {
|
|||
let meta = self.metadata.take().unwrap();
|
||||
|
||||
if let Some(content_type) = meta.content_type.map(Serde::into_inner) {
|
||||
if !SCRIPT_JS_MIMES.contains(&content_type.to_string().as_str()) {
|
||||
return Err(NetworkError::Internal("Invalid MIME type".to_owned()));
|
||||
let c = content_type.to_string();
|
||||
// The MIME crate includes params (e.g. charset=utf8) in the to_string
|
||||
// https://github.com/hyperium/mime/issues/120
|
||||
if let Some(ty) = c.split(';').next() {
|
||||
if !SCRIPT_JS_MIMES.contains(&ty) {
|
||||
return Err(NetworkError::Internal(format!("Invalid MIME type: {}", ty)));
|
||||
}
|
||||
} else {
|
||||
return Err(NetworkError::Internal("Empty MIME type".into()));
|
||||
}
|
||||
} else {
|
||||
return Err(NetworkError::Internal("No MIME type".into()));
|
||||
}
|
||||
|
||||
// Step 10.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue