-
-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Using string slices in a validated struct instead of strings causes a validation error if the field sent by the client contains newlines.
Here is the struct I noticed this issue on:
#[derive(Deserialize, Serialize, Validate)]
pub struct CreateFile<'r> {
#[validate(length(min = 1, max = 32))]
name: Option<&'r str>,
#[validate(length(min = 1, max = 300_000))]
content: &'r str,
}Sending a newline character in either field causes the server to respond with the following error:
{
"code": 422,
"message": "Unprocessable Entity. The request was well-formed but was unable to be followed due to semantic errors.",
"errors": null
}Replacing the content field type with String instead fixes the issue, which I did for the time being.
I'd however like to abstain from doing so since it is, as far as I'm aware, less efficient and Rocket discourages doing so.
This issue is not present when using the validator crate on its own (neither version v0.16.1 nor v0.18.1 are affected).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels