Skip to content

Commit 1a791f4

Browse files
authored
Fix parsing backslashes in request-targets (#57)
1 parent 84e10de commit 1a791f4

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/lib.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static URI_MAP: [bool; 256] = byte_map![
7171
// 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
7272
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
7373
// @ A B C D E F G H I J K L M N O
74-
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1,
74+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
7575
// P Q R S T U V W X Y Z [ \ ] ^ _
7676
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
7777
// ` a b c d e f g h i j k l m n o
@@ -983,6 +983,17 @@ mod tests {
983983
}
984984
}
985985

986+
req! {
987+
test_request_path_backslash,
988+
b"\n\nGET /\\?wayne\\=5 HTTP/1.1\n\n",
989+
|req| {
990+
assert_eq!(req.method.unwrap(), "GET");
991+
assert_eq!(req.path.unwrap(), "/\\?wayne\\=5");
992+
assert_eq!(req.version.unwrap(), 1);
993+
assert_eq!(req.headers.len(), 0);
994+
}
995+
}
996+
986997
req! {
987998
test_request_with_invalid_token_delimiter,
988999
b"GET\n/ HTTP/1.1\r\nHost: foo.bar\r\n\r\n",

tests/uri.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2437,9 +2437,13 @@ req! {
24372437

24382438
req! {
24392439
urltest_174,
2440-
b"GET \\.\\./ HTTP/1.1\r\nHost: \r\n\r\n",
2441-
Err(Error::Token),
2442-
|_r| {}
2440+
b"GET \\.\\./ HTTP/1.1\r\n\r\n",
2441+
|req| {
2442+
assert_eq!(req.method.unwrap(), "GET");
2443+
assert_eq!(req.path.unwrap(), "\\.\\./");
2444+
assert_eq!(req.version.unwrap(), 1);
2445+
assert_eq!(req.headers.len(), 0);
2446+
}
24432447
}
24442448

24452449

0 commit comments

Comments
 (0)