{"thread":{"id":"61690","subject":"[PATCH v3] git-send-email: Use sanitized address when reading mbox body","startedAt":"2024-06-28T08:49:15Z","lastAt":"2024-06-28T08:49:15Z","messageCount":1,"participants":["csókás"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"497800","messageId":"20240628084824.65007-2-csokas.bence@prolan.hu","threadId":"61690","inReplyTo":null,"subject":"[PATCH v3] git-send-email: Use sanitized address when reading mbox body","fromName":"","fromEmail":"csókás","sentAt":"2024-06-28T08:48:25Z","receivedAt":"2024-06-28T08:49:15Z","isPatch":true,"sender":{"key":"csókás","avatar":null},"body":"Commas and other punctuation marks in 'Cc: ', 'Signed-off-by: '\netc. lines mess with git-send-email. This is handled by calling\n`sanitize_address()` before adding addresses to @cc. This function\nwas already being called, but was only used for comparing it to\n$author for suppression purposes.\n\nNote that sanitization is only done for the message body, as\n`git format-patch` already RFC 2047-encodes mbox headers, so\nthose are generally trusted to be sane. Also note that\n`sanitize_address()` does not process the mailbox addresses,\nso it is up to `sendmail` to handle special characters there\n(e.g. there are mailboxes in regular use with '+'-es in them).\n\nSigned-off-by: Csókás, Bence <csokas.bence@prolan.hu>\n---\n git-send-email.perl   |  4 ++--\n t/t9001-send-email.sh | 51 +++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 53 insertions(+), 2 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex f0be4b4560..72044e5ef3 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -1847,9 +1847,9 @@ sub pre_process_file {\n \t\t\t\t\t$what, $_) unless $quiet;\n \t\t\t\tnext;\n \t\t\t}\n-\t\t\tpush @cc, $c;\n+\t\t\tpush @cc, $sc;\n \t\t\tprintf(__(\"(body) Adding cc: %s from line '%s'\\n\"),\n-\t\t\t\t$c, $_) unless $quiet;\n+\t\t\t\t$sc, $_) unless $quiet;\n \t\t}\n \t}\n \tclose $fh;\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex 58699f8e4e..0d62097c5a 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -1299,6 +1299,57 @@ test_expect_success $PREREQ 'utf8 sender is not duplicated' '\n \ttest_line_count = 1 msgfrom\n '\n \n+test_expect_success $PREREQ 'setup expect for cc list' \"\n+cat >expected-cc <<\\EOF\n+!recipient@example.com!\n+!author@example.com!\n+!one@example.com!\n+!odd_?=mail@example.com!\n+!doug@example.com!\n+!thor.au@example.com!\n+EOF\n+\"\n+\n+test_expect_success $PREREQ 'cc list is sanitized' '\n+\tclean_fake_sendmail &&\n+\ttest_commit weird_cc_body &&\n+\ttest_when_finished \"git reset --hard HEAD^\" &&\n+\tgit commit --amend -F - <<-EOF &&\n+\tTest Cc: sanitization.\n+\n+\tCc: Person, One <one@example.com>\n+\tReviewed-by: Füñný Nâmé <odd_?=mail@example.com>\n+\tReported-by: Douglas Reporter <doug@example.com> [from Jira profile]\n+\tReported-by: bugger on Jira\n+\tBugID: 12345\n+\tSigned-off-by: A. U. Thor <thor.au@example.com>\n+\tEOF\n+\tgit send-email -1 --to=recipient@example.com \\\n+\t\t--smtp-server=\"$(pwd)/fake.sendmail\" >actual-show-all-headers &&\n+\ttest_cmp expected-cc commandline1 &&\n+\ttest_grep \"^(body) Adding cc: \\\"Person, One\\\" <one@example.com>\" actual-show-all-headers &&\n+\ttest_grep \"^(body) Adding cc: =?UTF-8?q?F=C3=BC=C3=B1n=C3=BD=20N=C3=A2m=C3=A9?=\"\\\n+\" <odd_?=mail@example.com>\" actual-show-all-headers &&\n+\ttest_grep \"^(body) Adding cc: Douglas Reporter <doug@example.com>\" actual-show-all-headers &&\n+\ttest_grep \"^(body) Adding cc: \\\"A. U. Thor\\\" <thor.au@example.com>\" actual-show-all-headers\n+'\n+\n+test_expect_success $PREREQ 'quotes are sanitized in cc list' \"\n+\tclean_fake_sendmail &&\n+\ttest_commit quote_in_cc_body &&\n+\ttest_when_finished \\\"git reset --hard HEAD^\\\" &&\n+\tgit commit --amend -F - <<-EOF &&\n+\tQuotation marks sanitization in Cc:.\n+\n+\tCc: P'erson, One <one@example.com>\n+\tReported-by: \\\"Douglas 'Bug' Reporter\\\" <doug@example.com>\n+\tEOF\n+\tgit send-email -1 --to=recipient@example.com \\\n+\t\t--smtp-server=\\\"$(pwd)/fake.sendmail\\\" >actual-show-all-headers &&\n+\ttest_grep \\\"^(body) Adding cc: \\\\\\\"P'erson, One\\\\\\\" <one@example.com>\\\" actual-show-all-headers &&\n+\ttest_grep \\\"^(body) Adding cc: \\\\\\\"Douglas 'Bug' Reporter\\\\\\\" <doug@example.com>\\\" actual-show-all-headers\n+\"\n+\n test_expect_success $PREREQ 'sendemail.composeencoding works' '\n \tclean_fake_sendmail &&\n \tgit config sendemail.composeencoding iso-8859-1 &&\n-- \n2.34.1\n\n\n"}]}