🎉 Add parent directory link.

I was way overthinking this one.
main
_ 2020-10-31 15:46:24 +00:00
parent 0572de2ad0
commit be53772337
3 changed files with 9 additions and 5 deletions

View File

@ -22,7 +22,7 @@
<div class="entry_list"> <div class="entry_list">
<div> <div>
<a class="entry" href="https://example.com">../</a> <a class="entry" href="../">../</a>
</div> </div>
{{#each entries}} {{#each entries}}

View File

@ -257,13 +257,18 @@ pub async fn serve_all (
let encoded_path = &parts.uri [1..]; let encoded_path = &parts.uri [1..];
let path = percent_decode (encoded_path.as_bytes ()).decode_utf8 ().unwrap (); let path_s = percent_decode (encoded_path.as_bytes ()).decode_utf8 ().unwrap ();
let path = Path::new (&*path_s);
let mut full_path = PathBuf::from (root); let mut full_path = PathBuf::from (root);
full_path.push (&*path); full_path.push (path);
if let Ok (dir) = read_dir (&full_path).await { if let Ok (dir) = read_dir (&full_path).await {
serve_dir (handlebars, full_path.to_string_lossy (), dir).await serve_dir (
handlebars,
full_path.to_string_lossy (),
dir
).await
} }
else if let Ok (file) = File::open (&full_path).await { else if let Ok (file) = File::open (&full_path).await {
serve_file ( serve_file (

View File

@ -1,4 +1,3 @@
- Add ".." for parent directory
- Prevent directory traversal attacks - Prevent directory traversal attacks
- Set up tokens or something so clients can't trivially - Set up tokens or something so clients can't trivially
impersonate servers impersonate servers