-
Notifications
You must be signed in to change notification settings - Fork 824
Open
Description
Description
When updating a Gmail draft via gws gmail users drafts update, non-ASCII characters in CC, From, and BCC header display names result in mojibake. For example, Japanese display names are garbled when viewed in Gmail.
Steps to Reproduce
- Create or update a Gmail draft with a CC recipient that has a non-ASCII display name:
gws gmail users drafts update --params '{"userId": "me", "id": "<draft_id>"}' \ --json '{"message": {"raw": "<base64_encoded_message>"}}'
- The raw MIME message includes a CC header like:
Cc: "日本語名前" <user@example.com> - Open the draft in Gmail — the display name is garbled (e.g.,
日本語åinstead of日本語名前).
Expected Behavior
Non-ASCII display names in CC/From/BCC headers should be RFC 2047 encoded, e.g.:
Cc: =?UTF-8?B?5pel5pys6Kqe5ZCN5YmN?= <user@example.com>
Root Cause
In src/helpers/gmail/mod.rs, the MessageBuilder::build() method correctly applies encode_header_value() (RFC 2047 encoding) to the Subject header (line ~308), but the CC, From, and BCC headers (lines ~321-332) only use sanitize_header_value(), which strips CRLF characters but does not encode non-ASCII characters:
// Subject — correctly encoded
format!("Subject: {}", encode_header_value(&sanitize_header_value(self.subject)))
// CC — missing encode_header_value()
format!("\r\nCc: {}", sanitize_header_value(cc))Suggested Fix
Apply encode_header_value() to CC, From, and BCC headers, same as Subject:
if let Some(cc) = self.cc {
headers.push_str(&format!("\r\nCc: {}", encode_header_value(&sanitize_header_value(cc))));
}Same for from and bcc.
Environment
gwsinstalled via Homebrew on macOS (Apple Silicon)- Affected version: latest as of 2026-03-11
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels