]> Sergey Matveev's repositories - public-inbox.git/commitdiff
view: do not redundantly obfuscate addresses
authorEric Wong <e@yhbt.net>
Mon, 6 Apr 2020 08:32:52 +0000 (08:32 +0000)
committerEric Wong <e@yhbt.net>
Tue, 7 Apr 2020 19:37:39 +0000 (19:37 +0000)
We shouldn't rerun the address obfuscator on data we've
already run through.  Instead, run through the unescaped
text part and substitute the UTF-8 "\x{2022}" substitution
before it hits HTML escaping

Fixes: 9bdd81dc16ba6511 ("view: msg_iter calls add_body_text directly")
lib/PublicInbox/Hval.pm
lib/PublicInbox/View.pm

index 79005d2109499aae4b4abe6cf216a7583c909ad1..23233f0e7e979c8ff524e1864a46489a747512c9 100644 (file)
@@ -78,7 +78,7 @@ sub prurl ($$) {
 # However, &#8226; was chosen to make copy+paste errors more obvious
 sub obfuscate_addrs ($$;$) {
        my $ibx = $_[0];
-       my $repl = $_[2] || '&#8226;';
+       my $repl = $_[2] // '&#8226;';
        my $re = $ibx->{-no_obfuscate_re}; # regex of domains
        my $addrs = $ibx->{-no_obfuscate}; # { adddress => 1 }
        $_[1] =~ s/(([\w\.\+=\-]+)\@([\w\-]+\.[\w\.\-]+))/
index ddd94e48f730a2a493f913d9a43f3b6fd9dd1ac2..33b323dce248670dc1da248b795419470b4c0019 100644 (file)
@@ -532,6 +532,9 @@ sub add_text_body { # callback for msg_iter
        # link generation in diffs with the extra '%0D'
        $s =~ s/\r\n/\n/sg;
 
+       # will be escaped to `&#8226;' in HTML
+       obfuscate_addrs($ibx, $s, "\x{2022}") if $ibx->{obfuscate};
+
        # always support diff-highlighting, but we can't linkify hunk
        # headers for solver unless some coderepo are configured:
        my $diff;
@@ -589,8 +592,6 @@ sub add_text_body { # callback for msg_iter
                }
                undef $cur; # free memory
        }
-
-       obfuscate_addrs($ibx, $$rv) if $ibx->{obfuscate};
 }
 
 sub _msg_page_prepare_obuf {