From fcfc727295b67abe4568ab580316a62fa302a827 Mon Sep 17 00:00:00 2001 From: Dialga Date: Wed, 10 Jan 2024 16:56:15 +1300 Subject: [PATCH 1/4] actix-files: fix handling linebreaks in filenames (#3237) Co-authored-by: Rob Ede --- actix-files/CHANGES.md | 2 ++ actix-files/src/lib.rs | 8 +++++--- actix-files/src/named.rs | 8 ++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/actix-files/CHANGES.md b/actix-files/CHANGES.md index ac0fbfedc..2958eae66 100644 --- a/actix-files/CHANGES.md +++ b/actix-files/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +- Fix handling of special characters in filenames. + ## 0.6.4 - Fix handling of newlines in filenames. diff --git a/actix-files/src/lib.rs b/actix-files/src/lib.rs index 8ceb59bef..5b1f14eed 100644 --- a/actix-files/src/lib.rs +++ b/actix-files/src/lib.rs @@ -569,18 +569,20 @@ mod tests { } #[actix_rt::test] - async fn test_static_files_with_newlines() { + async fn test_static_files_with_special_characters() { // Create the file we want to test against ad-hoc. We can't check it in as otherwise // Windows can't even checkout this repository. let temp_dir = tempfile::tempdir().unwrap(); - let file_with_newlines = temp_dir.path().join("test\nnewline.text"); + let file_with_newlines = temp_dir.path().join("test\n\x0B\x0C\rnewline.text"); fs::write(&file_with_newlines, "Look at my newlines").unwrap(); let srv = test::init_service( App::new().service(Files::new("/", temp_dir.path()).index_file("Cargo.toml")), ) .await; - let request = TestRequest::get().uri("/test%0Anewline.text").to_request(); + let request = TestRequest::get() + .uri("/test%0A%0B%0C%0Dnewline.text") + .to_request(); let response = test::call_service(&srv, request).await; assert_eq!(response.status(), StatusCode::OK); diff --git a/actix-files/src/named.rs b/actix-files/src/named.rs index 02dc701ea..9e4a37737 100644 --- a/actix-files/src/named.rs +++ b/actix-files/src/named.rs @@ -139,8 +139,12 @@ impl NamedFile { _ => DispositionType::Attachment, }; - // Replace newlines in filenames which could occur on some filesystems. - let filename_s = filename.replace('\n', "%0A"); + // replace special characters in filenames which could occur on some filesystems + let filename_s = filename + .replace('\n', "%0A") // \n line break + .replace('\x0B', "%0B") // \v vertical tab + .replace('\x0C', "%0C") // \f form feed + .replace('\r', "%0D"); // \r carriage return let mut parameters = vec![DispositionParam::Filename(filename_s)]; if !filename.is_ascii() { From 33da4807092e39f11ac164d937a8e48b91c85862 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Wed, 10 Jan 2024 04:00:20 +0000 Subject: [PATCH 2/4] format project --- .prettierrc.yml | 2 +- actix-files/README.md | 6 +++++- actix-http-test/README.md | 6 +++++- actix-multipart-derive/README.md | 6 +++++- actix-multipart/README.md | 6 +++++- actix-router/README.md | 4 ++++ actix-web-actors/README.md | 6 +++++- actix-web-codegen/README.md | 6 +++++- awc/README.md | 6 +++++- justfile | 5 +++++ 10 files changed, 45 insertions(+), 8 deletions(-) diff --git a/.prettierrc.yml b/.prettierrc.yml index b61fd8974..d70303479 100644 --- a/.prettierrc.yml +++ b/.prettierrc.yml @@ -1,5 +1,5 @@ overrides: - - files: '*.md' + - files: "*.md" options: printWidth: 9999 proseWrap: never diff --git a/actix-files/README.md b/actix-files/README.md index d8d9e4f1f..c2dbc87f9 100644 --- a/actix-files/README.md +++ b/actix-files/README.md @@ -1,7 +1,9 @@ -# actix-files +# `actix-files` > Static file serving for Actix Web + + [![crates.io](https://img.shields.io/crates/v/actix-files?label=latest)](https://crates.io/crates/actix-files) [![Documentation](https://docs.rs/actix-files/badge.svg?version=0.6.4)](https://docs.rs/actix-files/0.6.4) ![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) @@ -11,6 +13,8 @@ [![Download](https://img.shields.io/crates/d/actix-files.svg)](https://crates.io/crates/actix-files) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) + + ## Documentation & Resources - [API Documentation](https://docs.rs/actix-files) diff --git a/actix-http-test/README.md b/actix-http-test/README.md index 4b286e603..e544c3616 100644 --- a/actix-http-test/README.md +++ b/actix-http-test/README.md @@ -1,7 +1,9 @@ -# actix-http-test +# `actix-http-test` > Various helpers for Actix applications to use during testing. + + [![crates.io](https://img.shields.io/crates/v/actix-http-test?label=latest)](https://crates.io/crates/actix-http-test) [![Documentation](https://docs.rs/actix-http-test/badge.svg?version=3.1.0)](https://docs.rs/actix-http-test/3.1.0) ![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) @@ -11,6 +13,8 @@ [![Download](https://img.shields.io/crates/d/actix-http-test.svg)](https://crates.io/crates/actix-http-test) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) + + ## Documentation & Resources - [API Documentation](https://docs.rs/actix-http-test) diff --git a/actix-multipart-derive/README.md b/actix-multipart-derive/README.md index cd5780c56..2beadefe3 100644 --- a/actix-multipart-derive/README.md +++ b/actix-multipart-derive/README.md @@ -1,7 +1,9 @@ -# actix-multipart-derive +# `actix-multipart-derive` > The derive macro implementation for actix-multipart-derive. + + [![crates.io](https://img.shields.io/crates/v/actix-multipart-derive?label=latest)](https://crates.io/crates/actix-multipart-derive) [![Documentation](https://docs.rs/actix-multipart-derive/badge.svg?version=0.6.1)](https://docs.rs/actix-multipart-derive/0.6.1) ![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) @@ -11,6 +13,8 @@ [![Download](https://img.shields.io/crates/d/actix-multipart-derive.svg)](https://crates.io/crates/actix-multipart-derive) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) + + ## Documentation & Resources - [API Documentation](https://docs.rs/actix-multipart-derive) diff --git a/actix-multipart/README.md b/actix-multipart/README.md index 8fe0328ab..16068510e 100644 --- a/actix-multipart/README.md +++ b/actix-multipart/README.md @@ -1,7 +1,9 @@ -# actix-multipart +# `actix-multipart` > Multipart form support for Actix Web. + + [![crates.io](https://img.shields.io/crates/v/actix-multipart?label=latest)](https://crates.io/crates/actix-multipart) [![Documentation](https://docs.rs/actix-multipart/badge.svg?version=0.6.1)](https://docs.rs/actix-multipart/0.6.1) ![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) @@ -11,6 +13,8 @@ [![Download](https://img.shields.io/crates/d/actix-multipart.svg)](https://crates.io/crates/actix-multipart) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) + + ## Documentation & Resources - [API Documentation](https://docs.rs/actix-multipart) diff --git a/actix-router/README.md b/actix-router/README.md index 7dc0c9010..7760b0331 100644 --- a/actix-router/README.md +++ b/actix-router/README.md @@ -1,5 +1,7 @@ # `actix-router` + + [![crates.io](https://img.shields.io/crates/v/actix-router?label=latest)](https://crates.io/crates/actix-router) [![Documentation](https://docs.rs/actix-router/badge.svg?version=0.5.2)](https://docs.rs/actix-router/0.5.2) ![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) @@ -9,6 +11,8 @@ [![Download](https://img.shields.io/crates/d/actix-router.svg)](https://crates.io/crates/actix-router) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) + + Resource path matching and router. diff --git a/actix-web-actors/README.md b/actix-web-actors/README.md index b2c30b954..c81fe64c1 100644 --- a/actix-web-actors/README.md +++ b/actix-web-actors/README.md @@ -1,7 +1,9 @@ -# actix-web-actors +# `actix-web-actors` > Actix actors support for Actix Web. + + [![crates.io](https://img.shields.io/crates/v/actix-web-actors?label=latest)](https://crates.io/crates/actix-web-actors) [![Documentation](https://docs.rs/actix-web-actors/badge.svg?version=4.2.0)](https://docs.rs/actix-web-actors/4.2.0) ![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) @@ -11,6 +13,8 @@ [![Download](https://img.shields.io/crates/d/actix-web-actors.svg)](https://crates.io/crates/actix-web-actors) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) + + ## Documentation & Resources - [API Documentation](https://docs.rs/actix-web-actors) diff --git a/actix-web-codegen/README.md b/actix-web-codegen/README.md index e9a1f9c7e..088f35756 100644 --- a/actix-web-codegen/README.md +++ b/actix-web-codegen/README.md @@ -1,7 +1,9 @@ -# actix-web-codegen +# `actix-web-codegen` > Routing and runtime macros for Actix Web. + + [![crates.io](https://img.shields.io/crates/v/actix-web-codegen?label=latest)](https://crates.io/crates/actix-web-codegen) [![Documentation](https://docs.rs/actix-web-codegen/badge.svg?version=4.2.2)](https://docs.rs/actix-web-codegen/4.2.2) ![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) @@ -11,6 +13,8 @@ [![Download](https://img.shields.io/crates/d/actix-web-codegen.svg)](https://crates.io/crates/actix-web-codegen) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) + + ## Documentation & Resources - [API Documentation](https://docs.rs/actix-web-codegen) diff --git a/awc/README.md b/awc/README.md index 035348fbd..424c86bba 100644 --- a/awc/README.md +++ b/awc/README.md @@ -1,13 +1,17 @@ -# awc (Actix Web Client) +# `awc` (Actix Web Client) > Async HTTP and WebSocket client library. + + [![crates.io](https://img.shields.io/crates/v/awc?label=latest)](https://crates.io/crates/awc) [![Documentation](https://docs.rs/awc/badge.svg?version=3.3.0)](https://docs.rs/awc/3.3.0) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/awc) [![Dependency Status](https://deps.rs/crate/awc/3.3.0/status.svg)](https://deps.rs/crate/awc/3.3.0) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) + + ## Documentation & Resources - [API Documentation](https://docs.rs/awc) diff --git a/justfile b/justfile index f2e449d85..2142e9bc5 100644 --- a/justfile +++ b/justfile @@ -1,6 +1,11 @@ _list: @just --list +# Format workspace. +fmt: + cargo +nightly fmt + npx -y prettier --write $(fd --type=file --hidden --extension=md --extension=yml) + # Document crates in workspace. doc: RUSTDOCFLAGS="--cfg=docsrs" cargo +nightly doc --no-deps --workspace --features=rustls,openssl From 83be07d77de4d463558769cc571bb16fd082c8af Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Wed, 10 Jan 2024 04:01:14 +0000 Subject: [PATCH 3/4] chore(actix-files): prepare release 0.6.5 --- actix-files/CHANGES.md | 2 ++ actix-files/Cargo.toml | 2 +- actix-files/README.md | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/actix-files/CHANGES.md b/actix-files/CHANGES.md index 2958eae66..9aa62ff77 100644 --- a/actix-files/CHANGES.md +++ b/actix-files/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +## 0.6.5 + - Fix handling of special characters in filenames. ## 0.6.4 diff --git a/actix-files/Cargo.toml b/actix-files/Cargo.toml index b7a272515..098d71bd7 100644 --- a/actix-files/Cargo.toml +++ b/actix-files/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-files" -version = "0.6.4" +version = "0.6.5" authors = [ "Nikolay Kim ", "Rob Ede ", diff --git a/actix-files/README.md b/actix-files/README.md index c2dbc87f9..e805d0418 100644 --- a/actix-files/README.md +++ b/actix-files/README.md @@ -5,11 +5,11 @@ [![crates.io](https://img.shields.io/crates/v/actix-files?label=latest)](https://crates.io/crates/actix-files) -[![Documentation](https://docs.rs/actix-files/badge.svg?version=0.6.4)](https://docs.rs/actix-files/0.6.4) +[![Documentation](https://docs.rs/actix-files/badge.svg?version=0.6.5)](https://docs.rs/actix-files/0.6.5) ![Version](https://img.shields.io/badge/rustc-1.68+-ab6000.svg) ![License](https://img.shields.io/crates/l/actix-files.svg)
-[![dependency status](https://deps.rs/crate/actix-files/0.6.4/status.svg)](https://deps.rs/crate/actix-files/0.6.4) +[![dependency status](https://deps.rs/crate/actix-files/0.6.5/status.svg)](https://deps.rs/crate/actix-files/0.6.5) [![Download](https://img.shields.io/crates/d/actix-files.svg)](https://crates.io/crates/actix-files) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) From 08a9c665680807d9129c4a6fc54fadd498c24e43 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Wed, 10 Jan 2024 04:03:29 +0000 Subject: [PATCH 4/4] docs(files: update readme from crate docs --- actix-files/README.md | 22 ++++++++++++++++------ justfile | 5 +++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/actix-files/README.md b/actix-files/README.md index e805d0418..df80e4047 100644 --- a/actix-files/README.md +++ b/actix-files/README.md @@ -1,7 +1,5 @@ # `actix-files` -> Static file serving for Actix Web - [![crates.io](https://img.shields.io/crates/v/actix-files?label=latest)](https://crates.io/crates/actix-files) @@ -15,8 +13,20 @@ -## Documentation & Resources + -- [API Documentation](https://docs.rs/actix-files) -- [Example Project](https://github.com/actix/examples/tree/master/basics/static-files) -- Minimum Supported Rust Version (MSRV): 1.68 +Static file serving for Actix Web. + +Provides a non-blocking service for serving static files from disk. + +## Examples + +```rust +use actix_web::App; +use actix_files::Files; + +let app = App::new() + .service(Files::new("/static", ".").prefer_utf8(true)); +``` + + diff --git a/justfile b/justfile index 2142e9bc5..42979f18c 100644 --- a/justfile +++ b/justfile @@ -14,3 +14,8 @@ doc: doc-watch: RUSTDOCFLAGS="--cfg=docsrs" cargo +nightly doc --no-deps --workspace --features=rustls,openssl --open cargo watch -- RUSTDOCFLAGS="--cfg=docsrs" cargo +nightly doc --no-deps --workspace --features=rustls,openssl + +# Update READMEs from crate root documentation. +update-readmes: && fmt + cd ./actix-files && cargo rdme --force + cd ./actix-router && cargo rdme --force