From 4f5b45317cfb941e260f1b16a8ccc088b44b933c Mon Sep 17 00:00:00 2001 From: Maciej Hirsz Date: Thu, 29 Oct 2020 18:16:33 +0100 Subject: [PATCH 1/2] Remove a panic in normalize middleware --- CHANGES.md | 3 +++ src/middleware/normalize.rs | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f30049c9d10..75e016619e9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -30,6 +30,9 @@ * Re-export bytes::Buf{Mut} in web module. [#1750] * Upgrade `pin-project` to `1.0`. +### Fixed +* Removed an occasional `unwrap` on `None` panic in `NormalizePathNormalization`. + [#1723]: https://github.com/actix/actix-web/pull/1723 [#1743]: https://github.com/actix/actix-web/pull/1743 [#1748]: https://github.com/actix/actix-web/pull/1748 diff --git a/src/middleware/normalize.rs b/src/middleware/normalize.rs index e0ecd90dc85..ac8ad71d52b 100644 --- a/src/middleware/normalize.rs +++ b/src/middleware/normalize.rs @@ -137,9 +137,9 @@ where // so the change can not be deduced from the length comparison if path != original_path { let mut parts = head.uri.clone().into_parts(); - let pq = parts.path_and_query.as_ref().unwrap(); + let query = parts.path_and_query.as_ref().and_then(|pq| pq.query()); - let path = if let Some(q) = pq.query() { + let path = if let Some(q) = query { Bytes::from(format!("{}?{}", path, q)) } else { Bytes::copy_from_slice(path.as_bytes()) From 09ae9c9934fa56592c120bcab6f814535b5bfe3d Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 1 Dec 2020 05:28:51 +0900 Subject: [PATCH 2/2] Move an entry to the unreleased section --- CHANGES.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 75e016619e9..1175aa54af8 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,7 @@ ## Unreleased - 2020-xx-xx ### Fixed * Ensure `actix-http` dependency uses same `serde_urlencoded`. +* Removed an occasional `unwrap` on `None` panic in `NormalizePathNormalization`. ## 3.3.0 - 2020-11-25 @@ -30,9 +31,6 @@ * Re-export bytes::Buf{Mut} in web module. [#1750] * Upgrade `pin-project` to `1.0`. -### Fixed -* Removed an occasional `unwrap` on `None` panic in `NormalizePathNormalization`. - [#1723]: https://github.com/actix/actix-web/pull/1723 [#1743]: https://github.com/actix/actix-web/pull/1743 [#1748]: https://github.com/actix/actix-web/pull/1748