Preserve raw bytes in IMAP APPEND#109
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 62fdff5430
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| steps' <- readIORef input | ||
| case steps' of | ||
| ReadLine line : rest -> writeIORef input rest >> return line | ||
| ReadBytes _ : _ -> assertFailure "expected test stream line, got bytes" |
There was a problem hiding this comment.
Return a ByteString on scripted read failures
When the new imap-parsers test target is built, these failure branches are type-checked as part of popLine :: IO ByteString/popBytes :: IO ByteString, but assertFailure from HUnit returns Assertion (IO ()). That makes the newly added test suite fail to compile before any tests can run; use a polymorphic throwing helper or follow the failure with an unreachable ByteString result.
Useful? React with 👍 / 👎.
afb5f56 to
6c71a13
Compare
Fixes #102.
appendFullcurrently splits the rendered message withBS.lines, computes a new literal size from those split lines, and sends each line withbsPutCrLf. That mutates already-rendered RFC 5322/MIME bytes: CRLF input becomes CRCRLF on the wire and the literal size no longer matches the original message size.This PR keeps the public API unchanged and sends the APPEND literal exactly as supplied:
BS.length mailDatamailDatais written once withbsPutRegression coverage:
IMAP.append conn "INBOX" "Subject: x\r\n\r\nBody\r\n"sends the exact raw message bytes after the APPEND command.Before the fix, the new regression failed with
{23}and doubled carriage returns. After the fix it passes with{20}and unchanged message bytes.Validation:
nix shell nixpkgs#cabal-install nixpkgs#ghc --command cabal test imap-parsers --test-show-details=directnix shell nixpkgs#cabal-install nixpkgs#ghc --command cabal build allnix shell nixpkgs#cabal-install nixpkgs#ghc --command cabal check(only the existingCHANGELOGdoc-place warning remains)git diff --checkNote: this includes the same
imap-parserstest-target setup andhttps://repository metadata fix as the other small upstream PRs because the branch is independently based on upstreammaster. It can be rebased to drop that overlap after the first test-target PR merges.