Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
maxbailly opened this issue Dec 20, 2024 · 0 comments
Open

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

maxbailly opened this issue Dec 20, 2024 · 0 comments

Comments

@maxbailly
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant