-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Preserve blank form values for urlencoded forms (option) #2439
Merged
Conversation
This file contains 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
Codecov Report
@@ Coverage Diff @@
## main #2439 +/- ##
=============================================
+ Coverage 87.138% 87.145% +0.007%
=============================================
Files 60 60
Lines 5046 5049 +3
Branches 908 908
=============================================
+ Hits 4397 4400 +3
Misses 477 477
Partials 172 172
Continue to review full report at Codecov.
|
ahopkins
requested changes
Apr 24, 2022
ahopkins
approved these changes
Apr 24, 2022
ChihweiLHBird
pushed a commit
to ChihweiLHBird/sanic
that referenced
this pull request
Jun 1, 2022
) * task(request.form): Add tests for blank values * fix(request): abstract form property to implement get_form(), allow for preserving of blanks * fix(request): hinting for parsed_form * fix(request): typing for parsed_files * fix(request): ignore type assumption * fix(request): mypy typechecking caused E501 when type set to ignore * fix(request): mypy is too stupid to parse continuations * fix(request): formatting * fix(request): fix annotation and return for get_form() * fix(request): linting, hinting
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.
This is a non-breaking update to form parsing based on a realistic expectation of being able to preserve blank values that are passed. As this currently works, using the default behavior of urllib.parse_qs, blank values are dropped, however this is sometimes not the preferred behavior. urllib.parse_qs has a parameter (keep_blank_values) that defaults to false, but can be set to true to ensure this is available. This fix allows for that option to be used by creating a new request property that can be updated.
closes #2427
refactor logic from the .form property to .get_form() method which will accept the optional parameter of keep_blank_values as a boolean. By default this is False, preserving the existing behavior. If set to True, will preserve blank values in x-www-form-urlencoded forms when request.form is accessed
New tests:
form keep blanks
form drop blanks (expected behavior)