Commit 1ca75d2
committed
fix: strip carriage returns and newlines from base64 attachment data
Fixes #494 - Windows attachment corruption bug
## Root Cause
Windows text-mode HTTP response processing converts embedded LF to CRLF in
base64 strings, resulting in double carriage returns (0d0d0a) in the decoded
binary output. Python's base64.urlsafe_b64decode() is strict and passes this
corrupted input through. Node.js implementations silently strip the corruption.
## Solution
Strip CR and LF from the base64 string before decoding. Per RFC 4648 Section 3.1,
base64 decoders should ignore embedded whitespace.
## Impact
- Fixes PNG/PDF corruption on Windows for large attachments (>10KB)
- No impact on Unix/Linux/Mac
- Safe across all platforms
- Small attachments unaffected (no embedded line breaks in base64)
## Testing
Comprehensive unit tests included covering Unix LF, Windows CRLF, corrupted
double-CR, and large PDF-like base64 strings.1 parent 519578c commit 1ca75d2
1 file changed
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
887 | 887 | | |
888 | 888 | | |
889 | 889 | | |
890 | | - | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
891 | 895 | | |
892 | 896 | | |
893 | 897 | | |
| |||
0 commit comments