Repository navigation
Conversation
…tive boundary Multipart parsing only matched quoted Content-Disposition values, so parts sent as `name=field` were skipped and reported as missing (422). The boundary parameter was matched case-sensitively, so `Boundary=` returned 415 missing_boundary. Accept unquoted token values in Content-Disposition (RFC 7578 uses the RFC 2183 syntax) and match the boundary parameter name case-insensitively (RFC 2045). Quoted values behave as before. closes aws-powertools#8909
|
Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need. |
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Issue number: closes #8909
Summary
Changes
Both changes are in
middlewares/openapi_validation.py._extract_header_paramnow accepts an unquoted token value (name=description) as well as a quoted string. RFC 7578 uses the RFC 2183 parameter syntax, where a value can be either. The segment anchoring from fix(event_handler): harden multipart and JSON body validation #8626 is unchanged, sonamestill doesn't match insidefilename._extract_multipart_boundarymatches theboundaryparameter name case-insensitively (RFC 2045). The boundary value itself is still taken as is.No existing tests were changed.
User experience
Before:
Content-Disposition: form-data; name=descriptionwas skipped, so the request returned 422 with every field reported as missing.Content-Type: multipart/form-data; Boundary=XyZreturned 415missing_boundary.After: both requests are parsed like their quoted, lowercase equivalents and return 200. Requests that already worked behave the same.
Verification
test_multipart_unquoted_content_disposition_params: unquoted name and filename,filename=beforename=, mixed quoting.test_multipart_boundary_parameter_name_is_case_insensitive:Boundary=andBOUNDARY=.developand pass with this change.pytest tests/functional/event_handler tests/unit/event_handler: 1301 passed, 1 skipped (the existing "Not implemented yet" AppSync test).ruff format --check,ruff checkandmypypass on the changed files.tests/events/apiGatewayProxyEvent.json: 422 and 415 ondevelop, 200 with this change.Content-Typeand body through unchanged, so the parsing is the same.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.