From: Eric Wong <e@80x24.org>
To: Kyle Meyer <kyle@kyleam.com>
Cc: meta@public-inbox.org
Subject: Re: archive links broken with obfuscate=true
Date: Fri, 9 Apr 2021 10:21:29 +0000 [thread overview]
Message-ID: <20210409102129.GA16787@dcvr> (raw)
In-Reply-To: <87a6q8p5qa.fsf@kyleam.com>
Kyle Meyer <kyle@kyleam.com> wrote:
> I've been testing out obfuscate=true a bit (which won't be a surprise to
> Eric, given a private email that was sent to both of us). One issue I
> noticed is that it breaks archive links. I've posted an example at
> <https://yhetil.org/obf/20201204120929.GA22736@dcvr/>:
>
> Reported-by: Kyle Meyer <kyle@kyleam•com>
> Link: https://public-inbox.org/meta/87360nlc44.fsf@kyleam•com/
Oops, I think the following fixes it, but not sure if there's a
better way to accomplish the same thing....
I worry the regexp change is susceptible to performance problems
from malicious inputs. I can't remember if something like this
triggers a pathological case or not, or if I'm confusing this
with another quirk that does (or quirks of another RE engine)
------------8<--------
Subject: [WIP] www: do not perform address obfuscation on URLs
---
lib/PublicInbox/Hval.pm | 10 ++++++----
t/hval.t | 4 ++++
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/lib/PublicInbox/Hval.pm b/lib/PublicInbox/Hval.pm
index d20f70ae..6f1a046c 100644
--- a/lib/PublicInbox/Hval.pm
+++ b/lib/PublicInbox/Hval.pm
@@ -82,15 +82,17 @@ sub obfuscate_addrs ($$;$) {
my $repl = $_[2] // '•';
my $re = $ibx->{-no_obfuscate_re}; # regex of domains
my $addrs = $ibx->{-no_obfuscate}; # { $address => 1 }
- $_[1] =~ s/(([\w\.\+=\-]+)\@([\w\-]+\.[\w\.\-]+))/
- my ($addr, $user, $domain) = ($1, $2, $3);
- if ($addrs->{$addr} || ((defined $re && $domain =~ $re))) {
+ $_[1] =~ s#(\S*?)(([\w\.\+=\-]+)\@([\w\-]+\.[\w\.\-]+))#
+ my ($beg, $addr, $user, $domain) = ($1, $2, $3, $4);
+ if (index($beg, '://') > 0) {
+ $beg.$addr;
+ } elsif ($addrs->{$addr} || ((defined $re && $domain =~ $re))) {
$addr;
} else {
$domain =~ s!([^\.]+)\.!$1$repl!;
$user . '@' . $domain
}
- /sge;
+ #sge;
}
# like format_sanitized_subject in git.git pretty.c with '%f' format string
diff --git a/t/hval.t b/t/hval.t
index 9d0dab7a..5afc2052 100644
--- a/t/hval.t
+++ b/t/hval.t
@@ -47,6 +47,10 @@ EOF
is($html, $exp, 'only obfuscated relevant addresses');
+$exp = 'https://example.net/foo@example.net';
+PublicInbox::Hval::obfuscate_addrs($ibx, my $res = $exp);
+is($res, $exp, 'does not obfuscate URL with Message-ID');
+
is(PublicInbox::Hval::to_filename('foo bar '), 'foo-bar',
'to_filename has no trailing -');
next prev parent reply other threads:[~2021-04-09 10:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-09 2:11 archive links broken with obfuscate=true Kyle Meyer
2021-04-09 10:21 ` Eric Wong [this message]
2021-04-09 22:45 ` Kyle Meyer
2021-04-09 23:37 ` Eric Wong
2021-04-10 4:06 ` Kyle Meyer
2021-04-10 5:15 ` Eric Wong
2021-04-10 19:49 ` Kyle Meyer
2021-04-11 5:32 ` [PATCH v2] www: do not obfuscate addresses in URLs Eric Wong
2021-04-11 5:34 ` Eric Wong
2021-04-11 14:45 ` Kyle Meyer
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=20210409102129.GA16787@dcvr \
--to=e@80x24.org \
--cc=kyle@kyleam.com \
--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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
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).