Skip to content

Commit

Permalink
Allow non-percent-encoded spaces in path
Browse files Browse the repository at this point in the history
The space character is not a reserved character. While it MAY be used in
percent-encoded form, this is not mandatory and it is acceptable to use
raw spaces in URL paths.

Add Space (0x20) to the list of characters that don't need to be
percent-encoded.
  • Loading branch information
WhyNotHugo committed Dec 28, 2024
1 parent 4e02046 commit 14633c6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/uri/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl PathAndQuery {
// percent-encoded in the path. If it should have been
// percent-encoded, then error.
#[rustfmt::skip]
0x21 |
0x20..=0x21 |
0x24..=0x3B |
0x3D |
0x40..=0x5F |
Expand Down Expand Up @@ -561,6 +561,11 @@ mod tests {
assert_eq!("/πŸ•", pq("/πŸ•").path());
}

#[test]
fn allow_space_in_path() {
assert_eq!("/dav/With Space/", pq("/dav/With Space/").path());
}

#[test]
fn allow_utf8_in_query() {
assert_eq!(Some("pizza=πŸ•"), pq("/test?pizza=πŸ•").query());
Expand Down

0 comments on commit 14633c6

Please sign in to comment.