Repository navigation
fix(http): a form body is read when its media type is not in lower case #422
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -132,9 +132,14 @@ final case class Request( | |
| * Both [[form]] and the `_method` override ask it, and they have to agree: an override that | ||
| * fired on a body [[form]] refuses to read would let a request that is not a form submission at | ||
| * all choose its own verb. | ||
| * | ||
| * The media type is compared without its parameters and without regard to case, as RFC 9110 | ||
| * says, so `Application/X-WWW-Form-Urlencoded; charset=UTF-8` is a form too. | ||
| */ | ||
| private[http] def isFormEncoded: Boolean = | ||
| header("Content-Type").exists(_.startsWith("application/x-www-form-urlencoded")) | ||
| header("Content-Type").exists( | ||
| _.takeWhile(_ != ';').trim.equalsIgnoreCase("application/x-www-form-urlencoded") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No test exercises RFC 9110 permits optional whitespace before Please add this value to the "application/x-www-form-urlencoded ; charset=UTF-8" |
||
| ) | ||
|
|
||
| /** A path parameter, converted. Throws [[BadRequest]], which the boundary maps to a 400. */ | ||
| def param[A](name: String)(using from: FromPath[A]): A = Request.param(pathParams, name) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR body says that the
_methodoverride now runs for a mixed case form type. No suite shows it: the mixed case values are only inRequestSuite, and that test readsrequest.formonly.I put the old case sensitive
startsWithcheck back inwithMethodOverrideonly, andMethodOverrideSuite,CsrfSuiteandRequestSuitestayed green (43 of 43). Thusformand the override can disagree again and no test fails. The scaladoc here says that they have to agree.Please add a test to
MethodOverrideSuite, for example "a mixed case form type is form encoded for the override too". A POST withContent-Type: Application/X-WWW-Form-Urlencodedand_method=PUTin the body becomes a PUT. Do the same check with_method=PUTin the query string.