Skip to content

Commit 5c40eca

Browse files
authored
Allow {, " and } in URI paths (#474)
1 parent 5b90e38 commit 5c40eca

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/uri/path.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ impl PathAndQuery {
5151
0x7C |
5252
0x7E => {},
5353

54+
// These are code points that are supposed to be
55+
// percent-encoded in the path but there are clients
56+
// out there sending them as is and httparse accepts
57+
// to parse those requests, so they are allowed here
58+
// for parity.
59+
//
60+
// For reference, those are code points that are used
61+
// to send requests with JSON directly embedded in
62+
// the URI path. Yes, those things happen for real.
63+
b'"' |
64+
b'{' | b'}' => {},
65+
5466
_ => return Err(ErrorKind::InvalidUriChar.into()),
5567
}
5668
}
@@ -527,6 +539,11 @@ mod tests {
527539
assert_eq!("qr=%3", pq("/a/b?qr=%3").query().unwrap());
528540
}
529541

542+
#[test]
543+
fn json_is_fine() {
544+
assert_eq!(r#"/{"bread":"baguette"}"#, pq(r#"/{"bread":"baguette"}"#).path());
545+
}
546+
530547
fn pq(s: &str) -> PathAndQuery {
531548
s.parse().expect(&format!("parsing {}", s))
532549
}

0 commit comments

Comments
 (0)