fix: RFC 2047 encode non-ASCII email subjects in +send helper#322
Conversation
🦋 Changeset detectedLatest commit: fb5b675 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue where non-ASCII characters in email subjects sent via the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly identifies the need to RFC 2047 encode non-ASCII email subjects and adds the necessary MIME headers. However, the current implementation has two critical issues regarding RFC 2047 compliance: it uses an incorrect Base64 variant and does not handle the mandatory 75-character line length limit for encoded words, which can lead to malformed subjects. I've provided suggestions to address these issues and improve the tests.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request addresses an important issue by RFC 2047 encoding non-ASCII email subjects and adding necessary MIME headers. However, the implementation of the encoding function has a critical flaw: it can split multi-byte UTF-8 characters, leading to corrupted subject lines. I've provided a detailed comment with a suggested fix to ensure chunking respects character boundaries. The rest of the changes, including the new tests, look good, though I'd recommend adding a test case for the issue I've identified.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request correctly fixes an issue with non-ASCII email subjects by implementing RFC 2047 encoding. The changes include adding the necessary MIME headers and comprehensive tests for the new encoding logic. My main feedback is to consider using a dedicated library for MIME handling, such as mail-headers, instead of a custom implementation. This would improve long-term correctness and maintainability by relying on a specialized, well-tested crate for a complex standard, and would also simplify the code.
Fix garbled non-ASCII email subjects in gmail +send by RFC 2047 encoding the Subject header and adding MIME-Version/Content-Type headers.
|
/gemini review |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #322 +/- ##
==========================================
+ Coverage 59.25% 59.36% +0.11%
==========================================
Files 36 36
Lines 12993 13046 +53
==========================================
+ Hits 7699 7745 +46
- Misses 5294 5301 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Fixes #266
Description
gmail +sendwrites the--subjectvalue directly into the RFC 2822Subject:header without encoding, causing non-ASCII characters (em dashes, CJK, accented characters) to render as garbled text (e.g.â€Âinstead of—)encode_header_value()that RFC 2047 base64-encodes the subject when it contains non-ASCII; ASCII subjects pass through unchangedMIME-VersionandContent-Type: text/plain; charset=utf-8headers to the raw messageDry Run Output:
Checklist:
AGENTS.mdguidelines (no generatedgoogle-*crates).cargo fmt --allto format the code perfectly.cargo clippy -- -D warningsand resolved all warnings.pnpx changeset) to document my changes.