Skip to content

Honor cc:/bcc: prefixes on recipients with quoted display names - #1613

Open
0z5a wants to merge 1 commit into
jenkinsci:mainfrom
0z5a:fix/cc-bcc-quoted-names
Open

0z5a wants to merge 1 commit into
jenkinsci:mainfrom
0z5a:fix/cc-bcc-quoted-names

Conversation

@0z5a

@0z5a 0z5a commented Nov 17, 2026

Copy link
Copy Markdown

A cc: or bcc: prefix in a recipient list is ignored when the recipient has a quoted display name, for example cc:"Mouse, Mickey" <mickey@example.com> or bcc:"Donald Duck" <donald@example.com>. For "Last, First" names the quotes cannot be dropped: unquoted, cc:Doe, Jane <jane@example.com> is split at the comma into Doe (Cc) and jane@example.com (To). RFC 5322 also requires the quotes for other names with special characters such as "J. Doe".

RecipientListStringAnalyser.findFirst searches for cc: + personal and cc:" + address.toString() + ", but not for cc:" + personal + ". With a quoted name it only finds the bare personal name, so the entry falls back to To. For a bcc: entry that means the address is put in the To header and is visible to all other recipients.

This adds the bcc:"<personal>" and cc:"<personal>" patterns to the search. The existing patterns are unchanged, so unquoted names, bare addresses and the JENKINS-52748 / JENKINS-55128 cases keep their current behaviour. Names containing escaped quotes ("Jane \"JD\" Doe") are still not matched; this change does not try to cover that.

Testing done

  • New EmailRecipientUtilsTest#testCCandBCCWithQuotedNames (goes through convertRecipientString with minnie@disney.com, cc:"Mouse, Mickey" <mickey@disney.com>, bcc:"Donald Duck" <donald@disney.com>): fails on main (To contains all three addresses), passes with the change.
  • New RecipientListStringAnalyserTest#getTypeForCcAndBccPrefixedQuotedNames (addresses taken from InternetAddress.parse, as in production): fails on main, passes with the change.
  • RecipientListStringAnalyserTest and both EmailRecipientUtilsTest classes pass (43 tests) with the change; spotless:check passes.

Note: #1595 also touches EmailRecipientUtils (switch reformat only); this change is in RecipientListStringAnalyser and the tests.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

This change was drafted with Claude Code (claude-opus-5-5); the test results above are from the runs described.

RecipientListStringAnalyser.findFirst searched for cc: + personal and
cc:" + address + ", but not for cc:" + personal + ". With a quoted
display name only the bare personal name matched, so the recipient was
classified as TO: a bcc: recipient with a quoted name ended up in the
To header. Search for the quoted personal name too.
@0z5a
0z5a requested a review from a team as a code owner November 17, 2026 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant