2 # Copyright (C) 2017-2021 all contributors <meta@public-inbox.org>
3 # License: AGPL-3+ <https://www.gnu.org/licenses/agpl-3.0.txt>
6 use PublicInbox::Config;
8 use_ok 'PublicInbox::Reply';
18 my $expect = shift @q;
19 my $res = PublicInbox::Config::squote_maybe($input);
20 is($res, $expect, "quote $input => $res");
23 my $mime = PublicInbox::Eml->new(<<'EOF');
24 From: from <from@example.com>
25 To: to <to@example.com>
27 Message-Id: <blah@example.com>
32 my $hdr = $mime->header_obj;
33 my $ibx = { -primary_address => 'primary@example.com' };
35 my ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
37 '--in-reply-to=blah@example.com',
38 '--to=from@example.com',
39 '--cc=cc@example.com',
40 '--cc=to@example.com',
41 "--subject='Re: hihi'"
44 is_deeply($arg, $exp, 'default reply is to :all');
45 $ibx->{replyto} = ':all';
46 ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
47 is_deeply($arg, $exp, '":all" also works');
49 $exp = [ '--in-reply-to=blah@example.com', '--to=primary@example.com',
50 "--subject='Re: hihi'" ];
51 $ibx->{replyto} = ':list';
52 ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
53 is_deeply($arg, $exp, '":list" works for centralized lists');
56 '--in-reply-to=blah@example.com',
57 '--to=primary@example.com',
58 '--cc=cc@example.com',
59 '--cc=to@example.com',
60 "--subject='Re: hihi'"
62 $ibx->{replyto} = ':list,Cc,To';
63 ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
64 is_deeply($arg, $exp, '":list,Cc,To" works for kinda centralized lists');
66 $ibx->{replyto} = 'new@example.com';
67 ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
68 $exp = [ '--in-reply-to=blah@example.com', '--to=new@example.com',
69 "--subject='Re: hihi'"
71 is_deeply($arg, $exp, 'explicit address works, too');
73 $ibx->{replyto} = ':all';
74 $ibx->{obfuscate} = 1;
75 ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
77 '--in-reply-to=blah@example.com',
78 '--to=from@example$(echo .)com',
79 '--cc=cc@example$(echo .)com',
80 '--cc=to@example$(echo .)com',
81 "--subject='Re: hihi'"
83 is_deeply($arg, $exp, 'address obfuscation works');
84 is($link, '', 'no mailto: link given');
86 $ibx->{replyto} = ':none=dead list';
87 $ibx->{obfuscate} = 1;
88 ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
89 is($$arg, 'dead list', ':none= works');