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

Forms that contain structures affected by encoding (such as SocketAddrV4) fail to parse #1425

Closed
lewisclark opened this issue Sep 7, 2020 · 0 comments
Labels
bug Deviation from the specification or expected behavior

Comments

@lewisclark
Copy link
Contributor

Bug Report

Version 0.4.5
OS: Debian 10 (Linux 4.19.0-10-cloud-amd64 #1 SMP Debian 4.19.132-1 (2020-07-24) x86_64 GNU/Linux)

A Form containing a SocketAddrV4 field is failing to parse input such as 127.0.0.1:80. I'm under the impression that this is because FromFormValue::from_form_value() and subsequently SocketAddrV4::from_str() is being called with the encoded address as a parameter (e.g. 127.0.0.1%3A80) instead of 127.0.0.1:80.

#[derive(FromForm)]
struct Input {
    ip: SocketAddrV4,
}

#[post("/test", data = "<input>")]
fn test(input: Form<Input>) {}

The above code will not parse input such as 127.0.0.1:80 because the colon ':' is encoded. This results in 127.0.0.1%3A80 being passed into FromFormValue::from_form_value() which will fail.

@lewisclark lewisclark changed the title Forms that contain structures affected by percent-encoding (such as SocketAddrV4) fail to parse Forms that contain structures affected by encoding (such as SocketAddrV4) fail to parse Sep 7, 2020
@SergioBenitez SergioBenitez added the bug Deviation from the specification or expected behavior label Sep 10, 2020
lewisclark added a commit to lewisclark/Rocket that referenced this issue Sep 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Deviation from the specification or expected behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants