Fix multipart upload parsing edge cases#22
Merged
Conversation
Owner
Author
|
issues |
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.
Motivation
POSThandling to correctly parse variable part headers and avoid assumptions about optional headers.Description
deal_post_data()with a loop that reads part headers until the blank separator and extracts the filename from combined headers, using helper functionsread_upload_line()andis_boundary_line()to robustly detect boundaries.Content-Lengthvalues and ensure the upload target fromtranslate_path()is an existing directory before writing the file.Content-Typeheader and avoid treating content that merely contains boundary-like text as a delimiter by matching only full boundary delimiter lines.target_pathwhen the upload does not complete successfully, and bump__version__to0.3.4and updateCHANGELOG.mdaccordingly.tests/test_simple_http_server.py(UploadParsingTests) and aDummyUploadHandlerto cover: missing partContent-Type, content containing boundary-like text, and interrupted uploads leaving no partial file.Testing
python3 -m py_compile simple_http_server.pysuccessfully.python3 -m unittest discover -s testsand all tests passed (8tests ran, OK).flake8checks butflake8is not installed in the environment, so those checks were not executed.Codex Task