diff options
author | Sven-Hendrik Haase <svenstaro@gmail.com> | 2020-08-24 21:33:46 +0000 |
---|---|---|
committer | Sven-Hendrik Haase <svenstaro@gmail.com> | 2020-08-24 23:15:27 +0000 |
commit | e0fe92687032385c08bd0e4109d3af002a211d1f (patch) | |
tree | 433bad0a0b3dc8e2afb6975c9bd2c996b37f7161 /tests | |
parent | Give up and just duplicate stuff (diff) | |
download | miniserve-e0fe92687032385c08bd0e4109d3af002a211d1f.tar.gz miniserve-e0fe92687032385c08bd0e4109d3af002a211d1f.zip |
Fix double-escaping (fixes #354)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/fixtures/mod.rs | 2 | ||||
-rw-r--r-- | tests/serve_request.rs | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/tests/fixtures/mod.rs b/tests/fixtures/mod.rs index cec912a..49ed7bd 100644 --- a/tests/fixtures/mod.rs +++ b/tests/fixtures/mod.rs @@ -8,7 +8,7 @@ pub type Error = Box<dyn std::error::Error>; /// File names for testing purpose #[allow(dead_code)] -pub static FILES: &[&str] = &["test.txt", "test.html", "test.mkv"]; +pub static FILES: &[&str] = &["test.txt", "test.html", "test.mkv", "test \" \' & < >.csv"]; /// Directory names for testing purpose #[allow(dead_code)] diff --git a/tests/serve_request.rs b/tests/serve_request.rs index cc0e059..43b16a0 100644 --- a/tests/serve_request.rs +++ b/tests/serve_request.rs @@ -45,9 +45,16 @@ fn serves_requests_with_non_default_port(tmpdir: TempDir, port: u16) -> Result<( let body = reqwest::blocking::get(format!("http://localhost:{}", port).as_str())? .error_for_status()?; let parsed = Document::from_read(body)?; + for &file in FILES { - assert!(parsed.find(|x: &Node| x.text() == file).next().is_some()); + let f = parsed.find(|x: &Node| x.text() == file).next().unwrap(); + dbg!(f.attr("href")); + assert_eq!( + format!("/{}", file), + percent_encoding::percent_decode_str(f.attr("href").unwrap()).decode_utf8_lossy(), + ); } + for &directory in DIRECTORIES { assert!(parsed .find(|x: &Node| x.text() == directory) |