1 # Copyright (C) 2017-2021 all contributors <meta@public-inbox.org>
2 # License: AGPL-3+ <https://www.gnu.org/licenses/agpl-3.0.txt>
7 use_ok 'PublicInbox::Reply';
17 my $expect = shift @q;
18 my $res = PublicInbox::Reply::squote_maybe($input);
19 is($res, $expect, "quote $input => $res");
22 my $mime = PublicInbox::Eml->new(<<'EOF');
23 From: from <from@example.com>
24 To: to <to@example.com>
26 Message-Id: <blah@example.com>
31 my $hdr = $mime->header_obj;
32 my $ibx = { -primary_address => 'primary@example.com' };
34 my ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
36 '--in-reply-to=blah@example.com',
37 '--to=from@example.com',
38 '--cc=cc@example.com',
39 '--cc=to@example.com',
40 "--subject='Re: hihi'"
43 is_deeply($arg, $exp, 'default reply is to :all');
44 $ibx->{replyto} = ':all';
45 ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
46 is_deeply($arg, $exp, '":all" also works');
48 $exp = [ '--in-reply-to=blah@example.com', '--to=primary@example.com',
49 "--subject='Re: hihi'" ];
50 $ibx->{replyto} = ':list';
51 ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
52 is_deeply($arg, $exp, '":list" works for centralized lists');
55 '--in-reply-to=blah@example.com',
56 '--to=primary@example.com',
57 '--cc=cc@example.com',
58 '--cc=to@example.com',
59 "--subject='Re: hihi'"
61 $ibx->{replyto} = ':list,Cc,To';
62 ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
63 is_deeply($arg, $exp, '":list,Cc,To" works for kinda centralized lists');
65 $ibx->{replyto} = 'new@example.com';
66 ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
67 $exp = [ '--in-reply-to=blah@example.com', '--to=new@example.com',
68 "--subject='Re: hihi'"
70 is_deeply($arg, $exp, 'explicit address works, too');
72 $ibx->{replyto} = ':all';
73 $ibx->{obfuscate} = 1;
74 ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
76 '--in-reply-to=blah@example.com',
77 '--to=from@example$(echo .)com',
78 '--cc=cc@example$(echo .)com',
79 '--cc=to@example$(echo .)com',
80 "--subject='Re: hihi'"
82 is_deeply($arg, $exp, 'address obfuscation works');
83 is($link, '', 'no mailto: link given');
85 $ibx->{replyto} = ':none=dead list';
86 $ibx->{obfuscate} = 1;
87 ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
88 is($$arg, 'dead list', ':none= works');