From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] reply: handle address obfuscation :<
Date: Fri, 23 Jun 2017 02:34:33 +0000 [thread overview]
Message-ID: <20170623023433.GA4155@dcvr> (raw)
In-Reply-To: <20170623023402.3638-1-e@80x24.org>
We can show users a lightly-obfuscated Bourne shell command
for invoking "git send-email" for address obfuscation. However,
I'm not sure if the mailto: arg will work effectively since
URL encoding is probably too well-known to be effective.
---
lib/PublicInbox/Reply.pm | 29 ++++++++++++++++++++++++-----
lib/PublicInbox/View.pm | 14 ++++++++++----
t/reply.t | 12 ++++++++++++
3 files changed, 46 insertions(+), 9 deletions(-)
diff --git a/lib/PublicInbox/Reply.pm b/lib/PublicInbox/Reply.pm
index 13ae052..0cd36fd 100644
--- a/lib/PublicInbox/Reply.pm
+++ b/lib/PublicInbox/Reply.pm
@@ -58,22 +58,41 @@ sub mailto_arg_link {
}
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
my $href = "mailto:$to?In-Reply-To=$irt${cc}&Subject=$subj";
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 687a0ac..1e2bcd5 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -61,6 +61,15 @@ sub msg_reply {
}
my ($arg, $link) = PublicInbox::Reply::mailto_arg_link($ibx, $hdr);
+
+ # mailto: link only works if address obfuscation is disabled
+ if ($link) {
+ $link = <<EOF;
+* If your mail client supports setting the <b>In-Reply-To</b> header
+ via mailto: links, try the <a
+href="$link">mailto: link</a></pre>
+EOF
+ }
push @$arg, '/path/to/YOUR_REPLY';
$arg = ascii_html(join(" \\\n ", '', @$arg));
<<EOF
@@ -86,10 +95,7 @@ $info
<a
href="$se_url">$se_url</a>
-
-* If your mail client supports setting the <b>In-Reply-To</b> header
- via mailto: links, try the <a
-href="$link">mailto: link</a></pre>
+$link
EOF
}
diff --git a/t/reply.t b/t/reply.t
index 640069c..719b4e4 100644
--- a/t/reply.t
+++ b/t/reply.t
@@ -64,4 +64,16 @@ $ibx->{replyto} = 'new@example.com';
$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();
--
EW
next prev parent reply other threads:[~2017-06-23 2:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-23 2:34 [PATCH] view: implement optional address obfuscation Eric Wong
2017-06-23 2:34 ` Eric Wong [this message]
2017-06-23 3:41 ` [PATCH 3/1] mbox: show application/mbox for obfuscated inboxes Eric Wong
2017-06-23 9:54 ` [PATCH 4/1] view: add newline before mailto: instructions in reply Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170623023433.GA4155@dcvr \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).