Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Codex review: needs real behavior proof before merge. What this changesThe PR preserves byte offsets when finding charset labels in malformed Content-Type headers. Example: Decode body byte 0x93 with Content-Type
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains This PR fixes a concrete charset-parsing defect still present on main; the production change is focused and preserves existing decoding behavior. Reviewed head: Before merge
Findings
Tests
Agent review detailsHow this fits togetherGmail read commands pass parsed message parts through the shared gmailcontent decoder, which converts base64url body data and MIME encodings into displayed text. flowchart TD
A[Gmail API message] --> B[Gmail read command]
B --> C[Shared body selection]
C --> D[Transfer decoding]
D --> E[Charset header parsing]
E --> F[Charset conversion]
F --> G[Text or JSON output]
Technical reviewBest possible solution: Land the byte-preserving search in the existing shared decoder with its focused regression coverage and a policy-compliant changelog entry. Do we have a high-confidence way to reproduce the issue? Source inspection establishes the offset mismatch and out-of-range slice for Is this the best way to solve the issue? The ASCII-only search directly restores the byte-offset invariant while retaining MIME parsing, fallback extraction, charset conversion, and existing UTF-8 handling. Full review comments:
Overall correctness: patch is correct AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against cfee06622536. Provenance checked
TestingProof path: unit tests only. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 27, 2026, 9:54 PM ET / November 28, 2026, 02:54 UTC. |
…has unusual bytes charsetLabelFromContentType searched for "charset=" in strings.ToLower(contentType) but sliced the original string at that index. Lower-casing changes the byte length of invalid UTF-8 bytes, U+0130 and U+212A, so a header with one of them before the parameter read the wrong label (the body decoded as mojibake) or sliced out of range (panic). Search an ASCII-only lower-case copy, which keeps every index.
4fb418e to
aeb53a7
Compare
What Problem This Solves
When gog reads a Gmail message, it picks the body's charset from the part's
Content-Typeheader, which the sender writes. If that header contains certain bytes beforecharset=(an invalid UTF-8 byte,İU+0130, or the Kelvin signKU+212A), gog reads the wrong charset label and shows the body as mojibake, or the read panics withslice bounds out of range.User Impact
Messages with such a header now decode in their declared charset, and reading them no longer crashes. Output and flags are unchanged for every other message.
Why This Change Was Made
charsetLabelFromContentTypefoundcharset=instrings.ToLower(contentType)but sliced the original string at that index. Lower-casing changes the byte length of those characters, so the index pointed somewhere else in the original. The fix searches an ASCII-only lower-case copy, which has the same length as the original, so the index is valid in both. Themime.ParseMediaTypepath before it is unchanged; only its fallback is affected.Evidence
TestDecodeBodyCharset_HeaderBytesBeforeLabel(four cases). Onmain(cfee066), three cases return the wrong text and the fourth panics. With the fix, all pass, along with the rest of./internal/gmailcontent.FuzzDecodeBodyCharset, is added. The same target found this bug in a downstream copy of this function in about 7 seconds; on this branch it ran 45 s (about 790k execs) clean with the fix.make lintreports 0 issues.AI disclosure: the bug was found by fuzzing and the fix was written with an AI coding assistant (Claude); I reviewed the change and ran the tests above.