Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added local directory listing feature. #32167

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
692c539
Added local directory listing feature.
Bobulous Apr 27, 2024
019c046
Grouped and sorted local directory listing. Added missing sub-directo…
Bobulous Apr 28, 2024
3138aa2
Fixed problem where directory path does not end with forward-slash.
Bobulous Apr 28, 2024
2b961d5
Addressed review feedback. Moved CSS into resources file. Replaced ta…
Bobulous Apr 30, 2024
cb6222c
Adjusted structure and styling of HTML for local directory listings. …
Bobulous May 4, 2024
0217c52
Reworked unit tests to make use of temporary directory, instead of ac…
Bobulous May 6, 2024
a0d6cfb
Merge branch 'main' into main
Bobulous May 28, 2024
2ddb8b1
Moved local directory listing feature behind a new Servo preference s…
Bobulous Jun 2, 2024
7ed4eaf
Merge branch 'main' into main
Bobulous Jun 2, 2024
b719e19
Merge branch 'main' into main
Bobulous Jun 5, 2024
7ef1c55
Merge branch 'main' into main
Bobulous Jun 8, 2024
d599958
Moved code and unit tests around based on review feedback. Further wo…
Bobulous Jun 8, 2024
b3470ed
Further work to satisfy review feedback, primarily related to unit te…
Bobulous Jun 9, 2024
f40e646
Merge branch 'main' into main
Bobulous Jun 9, 2024
ef319a7
Removed unwanted DirectorySummary container and reworked directory it…
Bobulous Jun 14, 2024
22f5107
Broke gather_directory_items into pieces using iteration methods.
Bobulous Jun 14, 2024
923ee9f
Merge branch 'main' into main
Bobulous Jun 14, 2024
4c12485
Merge branch 'main' into main
Bobulous Jun 17, 2024
1e56e71
Addressed further review feedback, mostly related to rustdoc comments.
Bobulous Jun 17, 2024
51a6a28
Merge branch 'main' into main
Bobulous Jun 18, 2024
a275e29
Removed unnecessary configuration from unit test file for local direc…
Bobulous Jun 18, 2024
4ed6535
Merge branch 'main' into main
Bobulous Jun 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ surfman = { version = "0.9", features = ["chains", "sm-angle", "sm-angle-default
syn = { version = "2", default-features = false, features = ["clone-impls", "derive", "parsing"] }
synstructure = "0.13"
thin-vec = "0.2.13"
# TODO: Migrate Servo from time 0.1 to 0.3 so that we don't need to build both versions.
time = "0.1.41"
time_03 = { package = "time", version = "0.3 ", features = ["std", "local-offset"] }
Bobulous marked this conversation as resolved.
Show resolved Hide resolved
to_shmem = { git = "https://github.com/servo/stylo", branch = "2024-05-15" }
tokio = "1"
tokio-rustls = "0.24"
Expand Down
5 changes: 4 additions & 1 deletion components/config/prefs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ mod gen {
background_color: i64,
#[serde(default = "black")]
foreground_color: i64,
}
},
},
css: {
animations: {
Expand Down Expand Up @@ -551,6 +551,9 @@ mod gen {
#[serde(rename = "network.http-cache.disabled")]
disabled: bool,
},
local_directory_listing: {
enabled: bool,
},
mime: {
sniff: bool,
}
Expand Down
1 change: 1 addition & 0 deletions components/net/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ servo_config = { path = "../config" }
servo_url = { path = "../url" }
sha2 = "0.10"
time = { workspace = true }
time_03 = { workspace = true }
tokio = { workspace = true, features = ["sync", "macros", "rt-multi-thread"] }
tokio-rustls = { workspace = true }
tokio-stream = "0.1"
Expand Down
9 changes: 5 additions & 4 deletions components/net/fetch/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ use crate::http_loader::{
determine_requests_referrer, http_fetch, set_default_accept, set_default_accept_language,
HttpState,
};
use crate::local_directory_listing;
use crate::subresource_integrity::is_response_integrity_valid;

lazy_static! {
Expand Down Expand Up @@ -689,7 +690,6 @@ async fn scheme_fetch(
context: &FetchContext,
) -> Response {
let url = request.current_url();

match url.scheme() {
"about" if url.path() == "blank" => create_blank_reply(url, request.timing_type()),

Expand Down Expand Up @@ -732,9 +732,10 @@ async fn scheme_fetch(
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(),
));
return match local_directory_listing::is_request_allowed(request) {
Err(refusal) => refusal,
Ok(()) => local_directory_listing::fetch(request, url, file_path),
};
}
}

Expand Down
1 change: 1 addition & 0 deletions components/net/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub mod hsts;
pub mod http_cache;
pub mod http_loader;
pub mod image_cache;
pub mod local_directory_listing;
pub mod mime_classifier;
pub mod resource_thread;
mod storage_thread;
Expand Down