mirror of
https://github.com/servo/servo.git
synced 2025-06-29 11:33:39 +01:00
Auto merge of #23593 - georgeroman:fix_panic_on_opening_directory, r=Manishearth
Fix panic on opening a directory <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors Continued from https://github.com/servo/servo/pull/23548 <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23593) <!-- Reviewable:end -->
This commit is contained in:
commit
1d2c0ba0bc
3 changed files with 17 additions and 2 deletions
|
@ -613,6 +613,14 @@ fn scheme_fetch(
|
||||||
}
|
}
|
||||||
if let Ok(file_path) = url.to_file_path() {
|
if let Ok(file_path) = url.to_file_path() {
|
||||||
if let Ok(file) = File::open(file_path.clone()) {
|
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.
|
// Get range bounds (if any) and try to seek to the requested offset.
|
||||||
// If seeking fails, bail out with a NetworkError.
|
// If seeking fails, bail out with a NetworkError.
|
||||||
let file_size = match file.metadata() {
|
let file_size = match file.metadata() {
|
||||||
|
|
|
@ -1,2 +1,7 @@
|
||||||
[get.py]
|
[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]
|
[navigate.py]
|
||||||
disabled: for now
|
[test_no_browsing_context]
|
||||||
|
expected: ERROR
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue