Properly escape URL parameters
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use serde::Deserialize;
|
||||
|
||||
use super::escape;
|
||||
use super::ApiErrorResponse;
|
||||
use super::Filter;
|
||||
use super::JsonError;
|
||||
@@ -108,7 +109,7 @@ impl Provider for Github {
|
||||
user: &str,
|
||||
) -> Result<Vec<GithubProject>, ApiErrorResponse<GithubApiErrorResponse>> {
|
||||
self.call_list(
|
||||
&format!("{GITHUB_API_BASEURL}/users/{user}/repos"),
|
||||
&format!("{GITHUB_API_BASEURL}/users/{}/repos", escape(user)),
|
||||
Some(ACCEPT_HEADER_JSON),
|
||||
)
|
||||
}
|
||||
@@ -118,7 +119,7 @@ impl Provider for Github {
|
||||
group: &str,
|
||||
) -> Result<Vec<GithubProject>, ApiErrorResponse<GithubApiErrorResponse>> {
|
||||
self.call_list(
|
||||
&format!("{GITHUB_API_BASEURL}/orgs/{group}/repos?type=all"),
|
||||
&format!("{GITHUB_API_BASEURL}/orgs/{}/repos?type=all", escape(group)),
|
||||
Some(ACCEPT_HEADER_JSON),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use serde::Deserialize;
|
||||
|
||||
use super::escape;
|
||||
use super::ApiErrorResponse;
|
||||
use super::Filter;
|
||||
use super::JsonError;
|
||||
@@ -125,7 +126,7 @@ impl Provider for Gitlab {
|
||||
user: &str,
|
||||
) -> Result<Vec<GitlabProject>, ApiErrorResponse<GitlabApiErrorResponse>> {
|
||||
self.call_list(
|
||||
&format!("{}/api/v4/users/{}/projects", self.api_url(), user),
|
||||
&format!("{}/api/v4/users/{}/projects", self.api_url(), escape(user)),
|
||||
Some(ACCEPT_HEADER_JSON),
|
||||
)
|
||||
}
|
||||
@@ -138,7 +139,7 @@ impl Provider for Gitlab {
|
||||
&format!(
|
||||
"{}/api/v4/groups/{}/projects?include_subgroups=true&archived=false",
|
||||
self.api_url(),
|
||||
group
|
||||
escape(group),
|
||||
),
|
||||
Some(ACCEPT_HEADER_JSON),
|
||||
)
|
||||
|
||||
@@ -28,6 +28,10 @@ enum ProjectResponse<T, U> {
|
||||
Failure(U),
|
||||
}
|
||||
|
||||
pub fn escape(s: &str) -> String {
|
||||
url_escape::encode_component(s).to_string()
|
||||
}
|
||||
|
||||
pub trait Project {
|
||||
fn into_repo_config(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user