]> Sergey Matveev's repositories - public-inbox.git/commitdiff
hval: only perform one substitution when obfuscating
authorEric Wong <e@80x24.org>
Thu, 29 Jun 2017 00:10:38 +0000 (00:10 +0000)
committerEric Wong <e@80x24.org>
Thu, 29 Jun 2017 00:11:40 +0000 (00:11 +0000)
Only one substitution character is necessary when obfuscating
email addresses.

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

index 800508861bcdb28dc435d121d7d1074d6814f2fd..8d36fc2ba6a38189193360e0059647688346eabf 100644 (file)
@@ -100,7 +100,7 @@ sub obfuscate_addrs ($$) {
                if ($addrs->{$addr} || ((defined $re && $domain =~ $re))) {
                        $addr;
                } else {
-                       $addr =~ s!([^\.]+)\.!$1&#8226;!g;
+                       $addr =~ s!([^\.]+)\.!$1&#8226;!;
                        $addr
                }
                /sge;
index dcbd838240c42639a3a5984771508067b9aa8fe8..a3712666d617511a5fc8fcc2b376244fc38b1014 100644 (file)
--- a/t/hval.t
+++ b/t/hval.t
@@ -17,6 +17,7 @@ hello@example.comm
 hello@example.com
 meta@public-inbox.org
 test@public-inbox.org
+test@a.b.c.org
 EOF
 
 PublicInbox::Hval::obfuscate_addrs($ibx, $html);
@@ -26,6 +27,7 @@ hello@example&#8226;comm
 hello@example.com
 meta@public-inbox.org
 test@public-inbox&#8226;org
+test@a&#8226;b.c.org
 EOF
 
 is($html, $exp, 'only obfuscated relevant addresses');