-
Notifications
You must be signed in to change notification settings - Fork 965
Open
Description
Bug
gws gmail +reply fails with Invalid To header when replying to emails where the sender's display name contains commas or parentheses (common with corporate email like Outlook/Exchange).
Reproduction
# Email from: "Anderson, Rich (CORP)" <Richard.Anderson@adp.com>
gws gmail +reply --message-id <id> --body "Test reply"{
"error": {
"code": 400,
"message": "Invalid To header",
"reason": "invalidArgument"
}
}Root Cause
In src/helpers/gmail/mod.rs, encode_address_header() reconstructs the address from parsed components but does not re-quote the display name:
// Line ~492
format!("{} <{}>", display, email)When the original From header is "Anderson, Rich (CORP)" <Richard.Anderson@adp.com>:
extract_display_name()strips the quotes →Anderson, Rich (CORP)encode_address_header()reconstructs it as:Anderson, Rich (CORP) <Richard.Anderson@adp.com>- The unquoted comma makes this look like two mailboxes to the Gmail API
- The unquoted
(CORP)is interpreted as an RFC 2822 comment - Gmail API rejects the malformed To header
Fix
The display name should be re-quoted when it contains RFC 2822 special characters (,, ;, (, ), <, >, @, \, ", ., [, ]):
// ASCII display name — quote if it contains special characters
if display.contains(|c: char| ",;()<>@\\\".[]".contains(c)) {
format!("\"{}\" <{}>", display.replace('"', "\\\""), email)
} else {
format!("{} <{}>", display, email)
}Environment
- gws version: 0.16.0
- macOS 15 (Darwin 25.2.0)
- Source email: Outlook/Exchange corporate email with
"Last, First (DEPT)"display name format
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels