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',
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 $ibx->{replyto} = ':list';
50 ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
51 is_deeply($arg, $exp, '":list" works for centralized lists');
54 '--in-reply-to=blah@example.com',
55 '--to=primary@example.com',
56 '--cc=cc@example.com',
57 '--cc=to@example.com',
59 $ibx->{replyto} = ':list,Cc,To';
60 ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
61 is_deeply($arg, $exp, '":list,Cc,To" works for kinda centralized lists');
63 $ibx->{replyto} = 'new@example.com';
64 ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
65 $exp = [ '--in-reply-to=blah@example.com', '--to=new@example.com' ];
66 is_deeply($arg, $exp, 'explicit address works, too');
68 $ibx->{replyto} = ':all';
69 $ibx->{obfuscate} = 1;
70 ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
72 '--in-reply-to=blah@example.com',
73 '--to=from@example$(echo .)com',
74 '--cc=cc@example$(echo .)com',
75 '--cc=to@example$(echo .)com',
77 is_deeply($arg, $exp, 'address obfuscation works');
78 is($link, '', 'no mailto: link given');
80 $ibx->{replyto} = ':none=dead list';
81 $ibx->{obfuscate} = 1;
82 ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
83 is($$arg, 'dead list', ':none= works');