Skip to content

Commit 091ee9a

Browse files
authored
feat(uri): allow utf8 char, not rfc 3986 compliant, in path and query (#715)
cc seanmonstar/httparse#178
1 parent a912445 commit 091ee9a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/uri/path.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl PathAndQuery {
5050
0x40..=0x5F |
5151
0x61..=0x7A |
5252
0x7C |
53-
0x7E => {}
53+
0x7E..=0xFF => {}
5454

5555
// These are code points that are supposed to be
5656
// percent-encoded in the path but there are clients
@@ -82,7 +82,7 @@ impl PathAndQuery {
8282
0x21 |
8383
0x24..=0x3B |
8484
0x3D |
85-
0x3F..=0x7E => {}
85+
0x3F..=0xFF => {}
8686

8787
b'#' => {
8888
fragment = Some(i);
@@ -556,6 +556,16 @@ mod tests {
556556
assert_eq!("qr=%3", pq("/a/b?qr=%3").query().unwrap());
557557
}
558558

559+
#[test]
560+
fn allow_utf8_in_path() {
561+
assert_eq!("/🍕", pq("/🍕").path());
562+
}
563+
564+
#[test]
565+
fn allow_utf8_in_query() {
566+
assert_eq!(Some("pizza=🍕"), pq("/test?pizza=🍕").query());
567+
}
568+
559569
#[test]
560570
fn json_is_fine() {
561571
assert_eq!(

0 commit comments

Comments
 (0)