Fix base64 multipart uploads with line breaks - #1122
Open
justadityaraj wants to merge 1 commit into
Open
Conversation
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.
Fixes #1120.
Problem
Base64 multipart bodies may contain CRLF line wrapping. Formidable counted those characters when choosing four-character decode chunks, so decoded file data could be truncated or corrupted.
Fix
Remove CRLF from base64 data before calculating the next quartet boundary. The multipart integration regression covers a line-wrapped base64 upload and verifies its decoded bytes.
User impact
Line-wrapped base64 uploads now preserve their original file contents.
Verification
node --experimental-vm-modules ./node_modules/jest/bin/jest.js --runInBand test/standalone/content-transfer-encoding.test.js— 2 tests passed, including the new regression.node --test ./test-node/**/*.test.js— 11 tests passed.node ./node_modules/eslint/bin/eslint.js --quiet src/plugins/multipart.js— passed.node ./node_modules/prettier/bin-prettier.js --check src/plugins/multipart.js test/standalone/content-transfer-encoding.test.js— passed.pnpm run build-package— Rollup build passed.Greptile Summary
This PR corrects streaming base64 decoding for multipart parts containing CRLF line wrapping.
Confidence Score: 5/5
The PR appears safe to merge with no actionable correctness or security issues identified.
The decoder removes only non-base64 CRLF bytes before calculating complete quartets, retains partial groups between parser events, and flushes the remaining valid data when the part ends.
Important Files Changed
Reviews (1): Last reviewed commit: "fix: ignore line breaks in base64 multip..." | Re-trigger Greptile
Context used: