seanmonstar / seanmonstar/httparse
double quotes in headers can not be parsed
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 713
- Forks
- 135
- PR merge metrics
- No merged PRs in 30d
Description
In the header name map, index 34 is false. So when parsing headers, the program will return Error::HeaderName when meeting double quotes(ascii number is 34) . However, bouble quotes in headers can be parsed correctly in chrome. Is this intentional or a bug?
Test Example:
#[test]
fn test_double_quotes() {
use std::mem;
let bytes= b"HTTP/1.1 200 OK\r\nServer: nginx/1.14.2\r\nDate: Mon, 25 Jan 2021 06:20:06 GMT\r\nContent-Type: image/png\r\nContent-Length: 24623\r\nConnection: keep-alive\r\n\"Access-Control-Allow-Origin: *\"\r\nAccept-Ranges: bytes\r\nAccess-Control-Allow-Origin: *\r\nCache-Control: 2592000\r\n\r\n";
let mut headers: [Header; 10] = unsafe { mem::uninitialized() };
let mut res = Response::new(&mut headers);
let parsed_res = res.parse(bytes);
println!("parsed res= {:?}", parsed_res);
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The header-name map is in src/lib.rs around line 96; start there and reproduce the supplied test_double_quotes case. Check the parser's expected handling of quoted header names, then establish the intended behavior with a regression test or documented decision.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100