Skip to content

Commit

Permalink
Allow {, " and } in URI paths (hyperium#474)
Browse files Browse the repository at this point in the history
  • Loading branch information
nox authored and Benxiang Ge committed Jul 26, 2021
1 parent 93e5f31 commit 78610de
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/uri/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ impl PathAndQuery {
0x7C |
0x7E => {},

// These are code points that are supposed to be
// percent-encoded in the path but there are clients
// out there sending them as is and httparse accepts
// to parse those requests, so they are allowed here
// for parity.
//
// For reference, those are code points that are used
// to send requests with JSON directly embedded in
// the URI path. Yes, those things happen for real.
b'"' |
b'{' | b'}' => {},

_ => return Err(ErrorKind::InvalidUriChar.into()),
}
}
Expand Down Expand Up @@ -527,6 +539,11 @@ mod tests {
assert_eq!("qr=%3", pq("/a/b?qr=%3").query().unwrap());
}

#[test]
fn json_is_fine() {
assert_eq!(r#"/{"bread":"baguette"}"#, pq(r#"/{"bread":"baguette"}"#).path());
}

fn pq(s: &str) -> PathAndQuery {
s.parse().expect(&format!("parsing {}", s))
}
Expand Down

0 comments on commit 78610de

Please sign in to comment.