mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Fix panic on opening a directory
This commit is contained in:
parent
97ad913dc2
commit
29bdcba1e8
3 changed files with 17 additions and 2 deletions
|
@ -615,6 +615,14 @@ fn scheme_fetch(
|
|||
}
|
||||
if let Ok(file_path) = url.to_file_path() {
|
||||
if let Ok(file) = File::open(file_path.clone()) {
|
||||
if let Ok(metadata) = file.metadata() {
|
||||
if metadata.is_dir() {
|
||||
return Response::network_error(NetworkError::Internal(
|
||||
"Opening a directory is not supported".into(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// Get range bounds (if any) and try to seek to the requested offset.
|
||||
// If seeking fails, bail out with a NetworkError.
|
||||
let file_size = match file.metadata() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue