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

TestForm throws InvalidHeaderValue with any word with letter r in filename or name fields #416

Closed
makorne opened this issue Oct 25, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@makorne
Copy link

makorne commented Oct 25, 2022

Expected Behavior

No errors

Actual Behavior

poem/src/test/form.rs:157] &content_disposition = "form-data; name="\\r""

called Result::unwrap() on an Err value: InvalidHeaderValue
thread 'test::form::tests::multipart' panicked at 'called Result::unwrap() on an Err value: InvalidHeaderValue', poem/src/test/form.rs:160:45

Steps to Reproduce the Problem

#[tokio::test]
async fn multipart() {
    let mut a = Vec::new();
    TestForm::new()
        .field(TestFormField::text("1").filename("r"))
        .field(TestFormField::text("2").name("r"))
        .into_async_read()
        .read_to_end(&mut a)
        .await
        .unwrap();
fn legal_str(s: impl AsRef<str>) -> String {
    s.as_ref()
        .replace('\\', "\\\\")
        .replace('\"', "\\\"")
        .replace('r', "\\\r")        <<<<< The error occurs because of this wrong replacing. Looks like it should be  .replace('\r' ...  
        .replace('\n', "\\\n")
}
@makorne makorne added the bug Something isn't working label Oct 25, 2022
@sunli829
Copy link
Collaborator

Thanks, fixed in master branch 😂

@sunli829
Copy link
Collaborator

Released in v1.3.48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants