seanmonstar / httparse

A push parser for the HTTP 1.x protocol in Rust.
https://docs.rs/httparse
Apache License 2.0
567 stars 111 forks source link

httparse 1.9.x breaks header parsing for certain cases #173

Closed mathpal closed 4 weeks ago

mathpal commented 4 weeks ago

A bug in the latest release leads to header values being incorrectly parsed when there is no space between header-name and header-value (header-name:headervalue\r\n includes : in the header value).

example:

    let mut headers = [httparse::EMPTY_HEADER; 1];
    let mut response = httparse::Response::new(&mut headers[..]);
    response.parse(b"HTTP/1.0 200 OK\r\nfoo:bar\r\n\r\n").unwrap();
    println!("{:?}", headers);
[Header { name: "foo", value: ":bar" }]

a quick bisect shows that https://github.com/seanmonstar/httparse/commit/b2625f38cc3a200e840861f2a3371eb8f5afdd73 introduced the regression.

seanmonstar commented 4 weeks ago

Thanks for the report, PR at #174.