From 34b58f415a40ef639c34167aa56245939b130245 Mon Sep 17 00:00:00 2001 From: Ali MJ Al-Nasrawy Date: Thu, 3 Jun 2021 15:35:09 +0300 Subject: [PATCH] test case --- actix-router/src/url.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/actix-router/src/url.rs b/actix-router/src/url.rs index d568e5af..e4522e5b 100644 --- a/actix-router/src/url.rs +++ b/actix-router/src/url.rs @@ -259,6 +259,16 @@ mod tests { assert_eq!(path.get("id").unwrap(), &test); } + #[test] + fn test_invalid_utf8() { + let invalid_utf8 = percent_encode((0x80..=0xff).collect::>().as_slice()); + let uri = Uri::try_from(format!("/{}", invalid_utf8)).unwrap(); + let path = Path::new(Url::new(uri)); + + // We should always get a valid utf8 string + assert!(String::from_utf8(path.path().as_bytes().to_owned()).is_ok()); + } + #[test] fn test_from_hex() { let hex = b"0123456789abcdefABCDEF";