From fe6d62200820f96739a7ab9591a11af653071013 Mon Sep 17 00:00:00 2001 From: Christian Legnitto <LegNeato@users.noreply.github.com> Date: Fri, 24 Jul 2020 17:27:38 -1000 Subject: [PATCH] Update percent_encoding (#715) Replaces https://github.com/graphql-rust/juniper/pull/702 --- juniper_actix/Cargo.toml | 1 - juniper_warp/Cargo.toml | 3 ++- juniper_warp/src/lib.rs | 11 +++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/juniper_actix/Cargo.toml b/juniper_actix/Cargo.toml index c5d2dc56..ba24d40b 100644 --- a/juniper_actix/Cargo.toml +++ b/juniper_actix/Cargo.toml @@ -26,7 +26,6 @@ thiserror = "1.0" juniper = { version = "0.14.2", path = "../juniper", features = ["expose-test-schema", "serde_json"] } env_logger = "0.7.1" log = "0.4.3" -percent-encoding = "1.0" tokio = { version = "0.2", features = ["rt-core", "macros", "blocking"] } actix-cors = "0.2.0" actix-identity = "0.2.0" diff --git a/juniper_warp/Cargo.toml b/juniper_warp/Cargo.toml index 684efa78..cf14ae32 100644 --- a/juniper_warp/Cargo.toml +++ b/juniper_warp/Cargo.toml @@ -27,5 +27,6 @@ warp = "0.2" env_logger = "0.7.1" juniper = { version = "0.14.2", path = "../juniper", features = ["expose-test-schema", "serde_json"] } log = "0.4.3" -percent-encoding = "1.0" +percent-encoding = "2" tokio = { version = "0.2", features = ["blocking", "macros", "rt-core"] } +url = "2" \ No newline at end of file diff --git a/juniper_warp/src/lib.rs b/juniper_warp/src/lib.rs index 0a3b046e..c2588f31 100644 --- a/juniper_warp/src/lib.rs +++ b/juniper_warp/src/lib.rs @@ -888,9 +888,16 @@ mod tests_http_harness { impl HttpIntegration for TestWarpIntegration { fn get(&self, url: &str) -> TestResponse { - use percent_encoding::{utf8_percent_encode, QUERY_ENCODE_SET}; + use percent_encoding::{utf8_percent_encode, AsciiSet, CONTROLS}; + use url::Url; - let url: String = utf8_percent_encode(&url.replace("/?", ""), QUERY_ENCODE_SET) + /// https://url.spec.whatwg.org/#query-state + const QUERY_ENCODE_SET: &AsciiSet = + &CONTROLS.add(b' ').add(b'"').add(b'#').add(b'<').add(b'>'); + + let url = Url::parse(&format!("http://localhost:3000{}", url)).expect("url to parse"); + + let url: String = utf8_percent_encode(url.query().unwrap_or(""), QUERY_ENCODE_SET) .into_iter() .collect::<Vec<_>>() .join("");