mirror of
https://git.proxmox.com/git/proxmox
synced 2025-10-18 23:10:16 +00:00
api/router: percent decode the components of the uri
those can contain percent encoded values, so we have to decode them before lookin up the path this is especially important for the 'MatchAll' branch when the parameter can contain some reserved characters Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
53e7e76b5f
commit
d7165108cb
@ -36,6 +36,7 @@ bytes = "0.5"
|
||||
futures = "0.3"
|
||||
http = "0.2"
|
||||
hyper = { version = "0.13", optional = true }
|
||||
percent-encoding = "2.1"
|
||||
rustyline = "6"
|
||||
serde_derive = "1.0"
|
||||
textwrap = "0.11"
|
||||
|
@ -8,6 +8,7 @@ use http::request::Parts;
|
||||
use http::{Method, Response};
|
||||
use hyper::Body;
|
||||
use serde_json::Value;
|
||||
use percent_encoding::percent_decode_str;
|
||||
|
||||
use crate::api::schema::{self, ObjectSchema, Schema};
|
||||
use crate::api::RpcEnvironment;
|
||||
@ -323,10 +324,15 @@ impl Router {
|
||||
|
||||
let (dir, remaining) = (components[0], &components[1..]);
|
||||
|
||||
let dir = match percent_decode_str(dir).decode_utf8() {
|
||||
Ok(dir) => dir.to_string(),
|
||||
Err(_) => return None,
|
||||
};
|
||||
|
||||
match self.subroute {
|
||||
None => {}
|
||||
Some(SubRoute::Map(dirmap)) => {
|
||||
if let Ok(ind) = dirmap.binary_search_by_key(&dir, |(name, _)| name) {
|
||||
if let Ok(ind) = dirmap.binary_search_by_key(&dir.as_str(), |(name, _)| name) {
|
||||
let (_name, router) = dirmap[ind];
|
||||
//println!("FOUND SUBDIR {}", dir);
|
||||
return router.find_route(remaining, uri_param);
|
||||
@ -334,7 +340,7 @@ impl Router {
|
||||
}
|
||||
Some(SubRoute::MatchAll { router, param_name }) => {
|
||||
//println!("URI PARAM {} = {}", param_name, dir); // fixme: store somewhere
|
||||
uri_param.insert(param_name.to_owned(), dir.into());
|
||||
uri_param.insert(param_name.to_owned(), dir);
|
||||
return router.find_route(remaining, uri_param);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user