From 4b1884b48efc673a2c36a88a45029ba1bd538148 Mon Sep 17 00:00:00 2001 From: Kornel Date: Sat, 11 Apr 2020 12:47:11 +0100 Subject: Escape arg --- github_v3/Cargo.toml | 7 ++++++- github_v3/src/lib.rs | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/github_v3/Cargo.toml b/github_v3/Cargo.toml index d4192f9..5f5247c 100644 --- a/github_v3/Cargo.toml +++ b/github_v3/Cargo.toml @@ -3,9 +3,13 @@ name = "github_v3" description = "Async GitHub API v3 client" version = "0.3.1" authors = ["Kornel "] -keywords = ["github", "rest-api", "async"] +keywords = ["github", "restful", "api", "async"] categories = ["web-programming", "web-programming::http-client"] edition = "2018" +readme = "README.md" +repository = "https://gitlab.com/crates.rs/crates.rs/-/tree/master/github_v3" +homepage = "https://lib.rs/github_v3" +license = "CC0-1.0" [dependencies] reqwest = { version = "0.10.1", features = ["json"] } @@ -16,6 +20,7 @@ serde_derive = "1.0.104" futures = "0.3.4" async-stream = "0.2.1" tokio = { version = "0.2.11", features = ["time"] } +urlencoding = "1.0.0" [dev-dependencies] tokio = { version = "0.2.11", features = ["rt-threaded", "macros", "time"] } diff --git a/github_v3/src/lib.rs b/github_v3/src/lib.rs index 4fb75bb..b13fa96 100644 --- a/github_v3/src/lib.rs +++ b/github_v3/src/lib.rs @@ -64,9 +64,12 @@ impl Builder { self } + /// Add a user-supplied argument to the request path, e.g. `.path("users").arg(username)` + /// + /// The arg is URL-escaped, so it's safe to use any user-supplied data. pub fn arg(mut self, arg: &str) -> Self { self.url.push('/'); - self.url.push_str(arg); + self.url.push_str(&urlencoding::encode(arg)); self } -- cgit v1.2.3