lib/PublicInbox/Reply.pm | 29 ++++++++++++++++++++++++----- lib/PublicInbox/View.pm | 14 ++++++++++---- t/reply.t | 12 ++++++++++++ diff --git a/lib/PublicInbox/Reply.pm b/lib/PublicInbox/Reply.pm index 13ae052e32641f08b15c351ac82273d35c377377..0cd36fdad542ee53e2cd9d95b3ef60bedc9d74e9 100644 --- a/lib/PublicInbox/Reply.pm +++ b/lib/PublicInbox/Reply.pm @@ -58,21 +58,40 @@ } } my @arg; + my $obfs = $ibx->{obfuscate}; my $subj = $hdr->header('Subject') || ''; $subj = "Re: $subj" unless $subj =~ /\bRe:/i; my $mid = $hdr->header_raw('Message-ID'); push @arg, '--in-reply-to='.squote_maybe(mid_clean($mid)); my $irt = mid_escape($mid); delete $cc->{$to}; - push @arg, "--to=$to"; - $to = uri_escape_utf8($to); - $subj = uri_escape_utf8($subj); + if ($obfs) { + my $arg_to = $to; + $arg_to =~ s/\./\$(echo .)/; + push @arg, "--to=$arg_to"; + } else { + push @arg, "--to=$to"; + $to = uri_escape_utf8($to); + $subj = uri_escape_utf8($subj); + } my @cc = sort values %$cc; $cc = ''; if (@cc) { - push(@arg, map { "--cc=$_" } @cc); - $cc = '&Cc=' . uri_escape_utf8(join(',', @cc)); + if ($obfs) { + push(@arg, map { + s/\./\$(echo .)/; + "--cc=$_"; + } @cc); + } else { + $cc = '&Cc=' . uri_escape_utf8(join(',', @cc)); + push(@arg, map { "--cc=$_" } @cc); + } } + + # I'm not sure if address obfuscation and mailto: links can + # be made compatible; and address obfuscation is misguided, + # anyways. + return (\@arg, '') if $obfs; # order matters, Subject is the least important header, # so it is last in case it's lost/truncated in a copy+paste diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 687a0acb9367737410d5ff4aae641513fd49b629..1e2bcd53ddc350a786a908d662a3236b6891476f 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -61,6 +61,15 @@ $info = qq(\n List information: $url\n); } my ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr); + + # mailto: link only works if address obfuscation is disabled + if ($link) { + $link = <In-Reply-To header + via mailto: links, try the mailto: link +EOF + } push @$arg, '/path/to/YOUR_REPLY'; $arg = ascii_html(join(" \\\n ", '', @$arg)); <$se_url - -* If your mail client supports setting the In-Reply-To header - via mailto: links, try the mailto: link +$link EOF } diff --git a/t/reply.t b/t/reply.t index 640069cb8cc5b4e961d216dc3b22b54425489cca..719b4e47565f06d3365ae43562e3c4ffcf657e4a 100644 --- a/t/reply.t +++ b/t/reply.t @@ -64,4 +64,16 @@ ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr); $exp = [ '--in-reply-to=blah@example.com', '--to=new@example.com' ]; is_deeply($arg, $exp, 'explicit address works, too'); +$ibx->{replyto} = ':all'; +$ibx->{obfuscate} = 1; +($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr); +$exp = [ + '--in-reply-to=blah@example.com', + '--to=from@example$(echo .)com', + '--cc=cc@example$(echo .)com', + '--cc=to@example$(echo .)com' +]; +is_deeply($arg, $exp, 'address obfuscation works'); +is($link, '', 'no mailto: link given'); + done_testing();