summaryrefslogtreecommitdiff
path: root/git-send-email.perl
diff options
context:
space:
mode:
Diffstat (limited to 'git-send-email.perl')
-rwxr-xr-xgit-send-email.perl37
1 files changed, 25 insertions, 12 deletions
diff --git a/git-send-email.perl b/git-send-email.perl
index 5d51697..303e03a 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -210,6 +210,7 @@ my %config_settings = (
"envelopesender" => \$envelope_sender,
"multiedit" => \$multiedit,
"confirm" => \$confirm,
+ "from" => \$sender,
);
# Handle Uncouth Termination
@@ -409,7 +410,7 @@ my %parse_alias = (
mailrc => sub { my $fh = shift; while (<$fh>) {
if (/^alias\s+(\S+)\s+(.*)$/) {
# spaces delimit multiple addresses
- $aliases{$1} = [ split(/\s+/, $2) ];
+ $aliases{$1} = [ quotewords('\s+', 0, $2) ];
}}},
pine => sub { my $fh = shift; my $f='\t[^\t]*';
for (my $x = ''; defined($x); $x = $_) {
@@ -537,7 +538,7 @@ if ($compose) {
print C <<EOT;
From $tpl_sender # This line is ignored.
-GIT: Lines beginning in "GIT: " will be removed.
+GIT: Lines beginning in "GIT:" will be removed.
GIT: Consider including an overall diffstat or table of contents
GIT: for the patch you are writing.
GIT:
@@ -552,8 +553,6 @@ EOT
}
close(C);
- my $editor = $ENV{GIT_EDITOR} || Git::config(@repo, "core.editor") || $ENV{VISUAL} || $ENV{EDITOR} || "vi";
-
if ($annotate) {
do_edit($compose_filename, @files);
} else {
@@ -570,7 +569,7 @@ EOT
my $in_body = 0;
my $summary_empty = 1;
while(<C>) {
- next if m/^GIT: /;
+ next if m/^GIT:/;
if ($in_body) {
$summary_empty = 0 unless (/^\n$/);
} elsif (/^\n$/) {
@@ -578,7 +577,7 @@ EOT
if ($need_8bit_cte) {
print C2 "MIME-Version: 1.0\n",
"Content-Type: text/plain; ",
- "charset=utf-8\n",
+ "charset=UTF-8\n",
"Content-Transfer-Encoding: 8bit\n";
}
} elsif (/^MIME-Version:/i) {
@@ -767,12 +766,20 @@ sub unquote_rfc2047 {
sub quote_rfc2047 {
local $_ = shift;
- my $encoding = shift || 'utf-8';
+ my $encoding = shift || 'UTF-8';
s/([^-a-zA-Z0-9!*+\/])/sprintf("=%02X", ord($1))/eg;
s/(.*)/=\?$encoding\?q\?$1\?=/;
return $_;
}
+sub is_rfc2047_quoted {
+ my $s = shift;
+ my $token = '[^][()<>@,;:"\/?.= \000-\037\177-\377]+';
+ my $encoded_text = '[!->@-~]+';
+ length($s) <= 75 &&
+ $s =~ m/^(?:"[[:ascii:]]*"|=\?$token\?$token\?$encoded_text\?=)$/o;
+}
+
# use the simplest quoting being able to handle the recipient
sub sanitize_address
{
@@ -784,7 +791,7 @@ sub sanitize_address
}
# if recipient_name is already quoted, do nothing
- if ($recipient_name =~ /^("[[:ascii:]]*"|=\?utf-8\?q\?.*\?=)$/) {
+ if (is_rfc2047_quoted($recipient_name)) {
return $recipient;
}
@@ -804,6 +811,10 @@ sub sanitize_address
}
+# Returns 1 if the message was sent, and 0 otherwise.
+# In actuality, the whole program dies when there
+# is an error sending a message.
+
sub send_message
{
my @recipients = unique_email_list(@to);
@@ -872,7 +883,7 @@ X-Mailer: git-send-email $gitversion
default => $ask_default);
die "Send this email reply required" unless defined $_;
if (/^n/i) {
- return;
+ return 0;
} elsif (/^q/i) {
cleanup_compose_files();
exit(0);
@@ -953,7 +964,7 @@ X-Mailer: git-send-email $gitversion
$smtp->data or die $smtp->message;
$smtp->datasend("$header\n$message") or die $smtp->message;
$smtp->dataend() or die $smtp->message;
- $smtp->ok or die "Failed to send $subject\n".$smtp->message;
+ $smtp->code =~ /250|200/ or die "Failed to send $subject\n".$smtp->message;
}
if ($quiet) {
printf (($dry_run ? "Dry-" : "")."Sent %s\n", $subject);
@@ -974,6 +985,8 @@ X-Mailer: git-send-email $gitversion
print "Result: OK\n";
}
}
+
+ return 1;
}
$reply_to = $initial_reply_to;
@@ -1134,10 +1147,10 @@ foreach my $t (@files) {
@cc = (@initial_cc, @cc);
- send_message();
+ my $message_was_sent = send_message();
# set up for the next message
- if ($thread &&
+ if ($thread && $message_was_sent &&
($chain_reply_to || !defined $reply_to || length($reply_to) == 0)) {
$reply_to = $message_id;
if (length $references > 0) {