Skip to content
This repository was archived by the owner on Jan 19, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion backend/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,16 @@ async fn main() -> std::io::Result<()> {
}

async fn index(req: HttpRequest) -> Result<HttpResponse, CompatErr> {
let path = webpage_path().join(req.match_info().query("filename"));
let base_path = webpage_path();
let filename = req.match_info().query("filename");
let path = base_path.join(filename);
let canonical_path = path.canonicalize().map_err(|e| {
error!("Error while canonicalizing path: {}", e);
CompatErr::from(SpecialErrors::InvalidPath)
})?;
if !canonical_path.starts_with(base_path) {
return Err(CompatErr::from(SpecialErrors::AccessDenied));
}
for file in &["", "index.html"] {
let path = if file.is_empty() {
path.to_owned()
Expand Down