git-send-email: treat field names as case-insensitively

Field names like To:, Cc:, etc. are case-insensitive; use a case-insensitive regexp to match them as such. Previously, git-send-email would fail to pick-up the addresses when in-body "fake" headers with different cases (e.g. lowercase "cc:") are manually inserted to the messages it was asked to send, even though the text will still show them. Signed-off-by: Nickolai Zeldovich <nickolai@csail.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nickolai Zeldovich committed Jan 6, 2013 at 20:34 UTC 6310071abfdf7a925b41a131d518d7636daa7259
1 file changed +5 -5
git-send-email.perl
+5 -5
@@ -1227,10 +1227,10 @@ foreach my $t (@files) {
1227 }
1228
1229 if (defined $input_format && $input_format eq 'mbox') {
1230 - if (/^Subject:\s+(.*)$/) {
1230 + if (/^Subject:\s+(.*)$/i) {
1231 $subject = $1;
1232 }
1233 - elsif (/^From:\s+(.*)$/) {
1233 + elsif (/^From:\s+(.*)$/i) {
1234 ($author, $author_encoding) = unquote_rfc2047($1);
1235 next if $suppress_cc{'author'};
1236 next if $suppress_cc{'self'} and $author eq $sender;
@@ -1238,14 +1238,14 @@ foreach my $t (@files) {
1238 $1, $_) unless $quiet;
1239 push @cc, $1;
1240 }
1241 - elsif (/^To:\s+(.*)$/) {
1241 + elsif (/^To:\s+(.*)$/i) {
1242 foreach my $addr (parse_address_line($1)) {
1243 printf("(mbox) Adding to: %s from line '%s'\n",
1244 $addr, $_) unless $quiet;
1245 push @to, sanitize_address($addr);
1246 }
1247 }
1248 - elsif (/^Cc:\s+(.*)$/) {
1248 + elsif (/^Cc:\s+(.*)$/i) {
1249 foreach my $addr (parse_address_line($1)) {
1250 if (unquote_rfc2047($addr) eq $sender) {
1251 next if ($suppress_cc{'self'});
@@ -1267,7 +1267,7 @@ foreach my $t (@files) {
1267 elsif (/^Message-Id: (.*)/i) {
1268 $message_id = $1;
1269 }
1270 - elsif (!/^Date:\s/ && /^[-A-Za-z]+:\s+\S/) {
1270 + elsif (!/^Date:\s/i && /^[-A-Za-z]+:\s+\S/) {
1271 push @xh, $_;
1272 }
1273