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;
if ($resp eq '' and defined $default) {
return $default;
}
- if ($resp =~ /$valid_re/) {
+ if (!defined $valid_re or $resp =~ /$valid_re/) {
return $resp;
}
}
}
# 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);
}