]> git.ipfire.org Git - thirdparty/git.git/blobdiff - git-send-email.perl
send-email: fix nasty bug in ask() function
[thirdparty/git.git] / git-send-email.perl
index fc153f9459a9b39aab159b16adf5d2b884e5285a..172b53c2d5b8ccad6a1bee592bccbe27d8f3127c 100755 (executable)
@@ -608,7 +608,7 @@ EOT
 
 sub ask {
        my ($prompt, %arg) = @_;
-       my $valid_re = $arg{valid_re} || ""; # "" matches anything
+       my $valid_re = $arg{valid_re};
        my $default = $arg{default};
        my $resp;
        my $i = 0;
@@ -624,7 +624,7 @@ sub ask {
                if ($resp eq '' and defined $default) {
                        return $default;
                }
-               if ($resp =~ /$valid_re/) {
+               if (!defined $valid_re or $resp =~ /$valid_re/) {
                        return $resp;
                }
        }
@@ -776,12 +776,13 @@ sub sanitize_address
        }
 
        # if recipient_name is already quoted, do nothing
-       if ($recipient_name =~ /^(".*"|=\?utf-8\?q\?.*\?=)$/) {
+       if ($recipient_name =~ /^("[[:ascii:]]*"|=\?utf-8\?q\?.*\?=)$/) {
                return $recipient;
        }
 
        # rfc2047 is needed if a non-ascii char is included
        if ($recipient_name =~ /[^[:ascii:]]/) {
+               $recipient_name =~ s/^"(.*)"$/$1/;
                $recipient_name = quote_rfc2047($recipient_name);
        }