slashes are not properly %-encoded in path parameters (#304)

This commit is contained in:
Adam Leventhal 2023-01-13 10:58:18 -08:00 committed by GitHub
parent a5fea0b061
commit 582e20c397
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -1,4 +1,4 @@
// Copyright 2022 Oxide Computer Company // Copyright 2023 Oxide Computer Company
#![allow(dead_code)] #![allow(dead_code)]
@ -366,6 +366,7 @@ where
} }
} }
// See https://url.spec.whatwg.org/#url-path-segment-string
const PATH_SET: &percent_encoding::AsciiSet = &percent_encoding::CONTROLS const PATH_SET: &percent_encoding::AsciiSet = &percent_encoding::CONTROLS
.add(b' ') .add(b' ')
.add(b'"') .add(b'"')
@ -375,7 +376,9 @@ const PATH_SET: &percent_encoding::AsciiSet = &percent_encoding::CONTROLS
.add(b'?') .add(b'?')
.add(b'`') .add(b'`')
.add(b'{') .add(b'{')
.add(b'}'); .add(b'}')
.add(b'/')
.add(b'%');
#[doc(hidden)] #[doc(hidden)]
pub fn encode_path(pc: &str) -> String { pub fn encode_path(pc: &str) -> String {

View File

@ -0,0 +1,8 @@
// Copyright 2023 Oxide Computer Company
use progenitor_client::encode_path;
#[test]
fn test_path_segment_encoding() {
assert_eq!(encode_path("192.168.0.0/24"), "192.168.0.0%2F24");
}