]> Sergey Matveev's repositories - public-inbox.git/commitdiff
hval: only allow domain obfuscation in address
authorEric Wong <e@80x24.org>
Tue, 16 Jan 2018 05:08:22 +0000 (05:08 +0000)
committerEric Wong <e@80x24.org>
Tue, 16 Jan 2018 05:11:09 +0000 (05:11 +0000)
Obfuscating username portions of the email address leads
to having subsequent parts of the address not being obfuscated;
which could mean we show someone else's email entirely.

In other words, obfuscating "john.doe@example.com" becomes
might mean "doe@example.com" is picked up by scanners.

In other news, email address obfuscation is still a horrible
usability issue and only exists to appease misguided people.

lib/PublicInbox/Hval.pm
t/hval.t

index 00a923eaecba6768e4ff5153983c0080b90f8309..0e199025adcec36d72d55e139900e1bf03f26edc 100644 (file)
@@ -95,13 +95,13 @@ sub obfuscate_addrs ($$) {
        my $ibx = $_[0];
        my $re = $ibx->{-no_obfuscate_re}; # regex of domains
        my $addrs = $ibx->{-no_obfuscate}; # { adddress => 1 }
-       $_[1] =~ s/([\w\.\+=\-]+\@([\w\-]+\.[\w\.\-]+))/
-               my ($addr, $domain) = ($1, $2);
+       $_[1] =~ s/(([\w\.\+=\-]+)\@([\w\-]+\.[\w\.\-]+))/
+               my ($addr, $user, $domain) = ($1, $2, $3);
                if ($addrs->{$addr} || ((defined $re && $domain =~ $re))) {
                        $addr;
                } else {
-                       $addr =~ s!([^\.]+)\.!$1&#8226;!;
-                       $addr
+                       $domain =~ s!([^\.]+)\.!$1&#8226;!;
+                       $user . '@' . $domain
                }
                /sge;
 }
index 2af4d2af5c8fc7119b25249f61ee6376efe1f68c..7915f4c9aa6ce744c33c71e8282053b84bd3fe11 100644 (file)
--- a/t/hval.t
+++ b/t/hval.t
@@ -18,6 +18,7 @@ hello@example.com
 meta@public-inbox.org
 test@public-inbox.org
 test@a.b.c.org
+te.st@example.org
 EOF
 
 PublicInbox::Hval::obfuscate_addrs($ibx, $html);
@@ -28,6 +29,7 @@ hello@example.com
 meta@public-inbox.org
 test@public-inbox&#8226;org
 test@a&#8226;b.c.org
+te.st@example&#8226;org
 EOF
 
 is($html, $exp, 'only obfuscated relevant addresses');