mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +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() {
|
||||
|
|
|
@ -1,2 +1,7 @@
|
|||
[get.py]
|
||||
disabled: for now
|
||||
[test_no_browsing_context]
|
||||
expected: ERROR
|
||||
|
||||
[test_get_current_url_nested_browsing_context]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
[navigate.py]
|
||||
disabled: for now
|
||||
[test_no_browsing_context]
|
||||
expected: ERROR
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue