@@ -681,6 +681,7 @@ sub ask {
681
681
my ($prompt , %arg ) = @_ ;
682
682
my $valid_re = $arg {valid_re };
683
683
my $default = $arg {default };
684
+ my $confirm_only = $arg {confirm_only };
684
685
my $resp ;
685
686
my $i = 0;
686
687
return defined $default ? $default : undef
@@ -698,6 +699,12 @@ sub ask {
698
699
if (!defined $valid_re or $resp =~ / $valid_re / ) {
699
700
return $resp ;
700
701
}
702
+ if ($confirm_only ) {
703
+ my $yesno = $term -> readline(" Are you sure you want to use <$resp > [y/N]? " );
704
+ if (defined $yesno && $yesno =~ / y/i ) {
705
+ return $resp ;
706
+ }
707
+ }
701
708
}
702
709
return undef ;
703
710
}
@@ -745,13 +752,15 @@ sub file_declares_8bit_cte {
745
752
if (!defined $sender ) {
746
753
$sender = $repoauthor || $repocommitter || ' ' ;
747
754
$sender = ask(" Who should the emails appear to be from? [$sender ] " ,
748
- default => $sender );
755
+ default => $sender ,
756
+ valid_re => qr /\@ .*\. / , confirm_only => 1);
749
757
print " Emails will be sent from: " , $sender , " \n " ;
750
758
$prompting ++;
751
759
}
752
760
753
761
if (!@initial_to && !defined $to_cmd ) {
754
- my $to = ask(" Who should the emails be sent to? " );
762
+ my $to = ask(" Who should the emails be sent to? " ,
763
+ valid_re => qr /\@ .*\. / , confirm_only => 1);
755
764
push @initial_to , parse_address_line($to ) if defined $to ; # sanitized/validated later
756
765
$prompting ++;
757
766
}
@@ -777,7 +786,8 @@ sub expand_one_alias {
777
786
778
787
if ($thread && !defined $initial_reply_to && $prompting ) {
779
788
$initial_reply_to = ask(
780
- " Message-ID to be used as In-Reply-To for the first email? " );
789
+ " Message-ID to be used as In-Reply-To for the first email? " ,
790
+ valid_re => qr /\@ .*\. / , confirm_only => 1);
781
791
}
782
792
if (defined $initial_reply_to ) {
783
793
$initial_reply_to =~ s / ^\s *<?// ;
0 commit comments