From 681ba770a11bb9e8a0143b1090dc0bdd0e67fb97 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Tue, 5 Jan 2021 19:57:51 +0100 Subject: [PATCH] check all path components --- src/main.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index ddeeefd..b1549dc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -183,9 +183,12 @@ async fn send_response(url: Url, stream: &mut TlsStream) -> Result { } // Do not serve anything that looks like a hidden file. - if !ARGS.serve_secret && path.file_name().map_or(false, |name| { - name.to_str().map_or(false, |name| name.starts_with(".")) - }) { + if !ARGS.serve_secret + && path + .iter() + .filter_map(|component| component.to_str()) + .any(|component| component.starts_with(".")) + { return send_header(stream, 52, &["If I told you, it would not be a secret."]).await; }