unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH] hval: only allow domain obfuscation in address
@ 2018-01-16  5:08 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2018-01-16  5:08 UTC (permalink / raw)
  To: meta

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 | 8 ++++----
 t/hval.t                | 2 ++
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/Hval.pm b/lib/PublicInbox/Hval.pm
index 00a923e..0e19902 100644
--- a/lib/PublicInbox/Hval.pm
+++ b/lib/PublicInbox/Hval.pm
@@ -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•!;
-			$addr
+			$domain =~ s!([^\.]+)\.!$1•!;
+			$user . '@' . $domain
 		}
 		/sge;
 }
diff --git a/t/hval.t b/t/hval.t
index 2af4d2a..7915f4c 100644
--- 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•org
 test@a•b.c.org
+te.st@example•org
 EOF
 
 is($html, $exp, 'only obfuscated relevant addresses');
-- 
EW


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-01-16  5:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-16  5:08 [PATCH] hval: only allow domain obfuscation in address Eric Wong

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).