Skip to content

Request::parse() accepts invalid methods. #196

Description

@maxbailly

This issue seems to be related to #161.


Consider this example :

#[test]
fn invalid_methods() {
    let src = "\"some,unvalid%GET{}:; / HTTP/1.1\r\nHost: 127.0.0.1:80\r\n\r\n";

    let mut headers = [httparse::EMPTY_HEADER; 32];
    let mut req = httparse::Request::new(&mut headers);

    let status = req.parse(src.as_bytes()).unwrap();
    assert!(status.is_complete());
    assert_eq!(req.method, Some("\"some,unvalid%GET{}:;"))
}

From the MDN and my understanding of the RFC, methods MUST be defined by the following grammar:

tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." /
        "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions