1 # Copyright (C) 2017 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 = Email::MIME->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',
42 is_deeply($arg, $exp, 'default reply is to :all');
43 $ibx->{replyto} = ':all';
44 ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
45 is_deeply($arg, $exp, '":all" also works');
47 $exp = [ '--in-reply-to=blah@example.com', '--to=primary@example.com' ];
48 $ibx->{replyto} = ':list';
49 ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
50 is_deeply($arg, $exp, '":list" works for centralized lists');
53 '--in-reply-to=blah@example.com',
54 '--to=primary@example.com',
55 '--cc=cc@example.com',
58 $ibx->{replyto} = ':list,Cc,To';
59 ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
60 is_deeply($arg, $exp, '":list,Cc,To" works for kinda centralized lists');
62 $ibx->{replyto} = 'new@example.com';
63 ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
64 $exp = [ '--in-reply-to=blah@example.com', '--to=new@example.com' ];
65 is_deeply($arg, $exp, 'explicit address works, too');
67 $ibx->{replyto} = ':all';
68 $ibx->{obfuscate} = 1;
69 ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
71 '--in-reply-to=blah@example.com',
72 '--to=from@example$(echo .)com',
73 '--cc=cc@example$(echo .)com',
74 '--cc=to@example$(echo .)com'
76 is_deeply($arg, $exp, 'address obfuscation works');
77 is($link, '', 'no mailto: link given');