Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-gmail-cc-header-case.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@googleworkspace/cli": patch
---

Preserve Gmail Cc recipients when the API returns a differently cased header name.
16 changes: 15 additions & 1 deletion crates/google-workspace-cli/src/helpers/gmail/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ fn parse_message_headers(headers: &[Value]) -> ParsedMessageHeaders {
"From" => parsed.from = value.to_string(),
"Reply-To" => append_address_list_header_value(&mut parsed.reply_to, value),
"To" => append_address_list_header_value(&mut parsed.to, value),
"Cc" => append_address_list_header_value(&mut parsed.cc, value),
_ if name.eq_ignore_ascii_case("Cc") => {
append_address_list_header_value(&mut parsed.cc, value)
}
"Subject" => parsed.subject = value.to_string(),
"Date" => parsed.date = value.to_string(),
"Message-ID" | "Message-Id" => parsed.message_id = value.to_string(),
Expand Down Expand Up @@ -2034,6 +2036,18 @@ mod tests {
assert!(to.contains("alice@example.com"));
}

#[test]
fn test_parse_message_headers_preserves_cc_regardless_of_header_case() {
let headers = vec![
json!({"name": "CC", "value": "alice@example.com"}),
json!({"name": "cc", "value": "bob@example.com"}),
];

let parsed = parse_message_headers(&headers);

assert_eq!(parsed.cc, "alice@example.com, bob@example.com");
}

#[test]
fn test_to_mb_address_with_display_name() {
let mailbox = Mailbox::parse("Alice Smith <alice@example.com>");
Expand Down
Loading