fix(gmail): RFC 2047 encode draft address headers#458
fix(gmail): RFC 2047 encode draft address headers#458sonwr wants to merge 1 commit intogoogleworkspace:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 4928d9b 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 |
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 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 addresses an issue with non-ASCII characters in email address headers by applying RFC 2047 encoding to From, Cc, and Bcc values. This is a good fix that improves email format compliance. The change is supported by a new test case. However, my review found that the To header is not being encoded, which is inconsistent with how Subject, From, Cc, and Bcc are handled. This oversight could lead to malformed emails if the To field contains non-ASCII display names. I've recommended that the To header also be encoded to ensure all address headers are treated consistently.
| if let Some(from) = self.from { | ||
| headers.push_str(&format!("\r\nFrom: {}", sanitize_header_value(from))); | ||
| headers.push_str(&format!( | ||
| "\r\nFrom: {}", | ||
| encode_header_value(&sanitize_header_value(from)) | ||
| )); | ||
| } |
There was a problem hiding this comment.
While this change correctly applies RFC 2047 encoding to the From, Cc, and Bcc headers, the To header is not being encoded. This is inconsistent and could lead to malformed emails if the To field contains non-ASCII characters in display names (e.g., "日本語名前" <user@example.com>).
For correctness and consistency with other address headers, the To header value should also be passed through encode_header_value. The To header is currently only sanitized on line 485.
Description
Fixes #404.
This updates Gmail draft message building to RFC 2047 encode sanitized non-ASCII
From,Cc, andBccheader values, matching the existingSubjecthandling.Reproduction:
origin/main,cargo test message_builder_encodes_non_ascii_optional_headers -- --nocapturefailed because optional draft address headers were emitted as raw UTF-8.Dry Run Output:
Not applicable.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.