]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/View.pm
view: do not redundantly obfuscate addresses
[public-inbox.git] / lib / PublicInbox / View.pm
index f0584cb7f0ee0211f538e4aca55ee9ac328273b9..33b323dce248670dc1da248b795419470b4c0019 100644 (file)
@@ -482,17 +482,6 @@ sub multipart_text_as_html {
        msg_iter($_[0], \&add_text_body, $_[1], 1);
 }
 
-sub flush_quote {
-       my ($s, $l, $quot) = @_;
-
-       my $rv = $l->to_html($$quot);
-
-       # we use a <span> here to allow users to specify their own
-       # color for quoted text
-       $$quot = undef;
-       $$s .= qq(<span\nclass="q">) . $rv . '</span>'
-}
-
 sub attach_link ($$$$;$) {
        my ($ctx, $ct, $p, $fn, $err) = @_;
        my ($part, $depth, @idx) = @$p;
@@ -543,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;
@@ -577,7 +569,7 @@ sub add_text_body { # callback for msg_iter
 
        # split off quoted and unquoted blocks:
        my @sections = PublicInbox::MsgIter::split_quotes($s);
-       $s = '';
+       undef $s; # free memory
        my $rv = $ctx->{obuf};
        if (defined($fn) || $depth > 0 || $err) {
                # badly-encoded message with $err? tell the world about it!
@@ -587,17 +579,19 @@ sub add_text_body { # callback for msg_iter
        my $l = $ctx->{-linkify} //= PublicInbox::Linkify->new;
        foreach my $cur (@sections) {
                if ($cur =~ /\A>/) {
-                       flush_quote($rv, $l, \$cur);
+                       # we use a <span> here to allow users to specify
+                       # their own color for quoted text
+                       $$rv .= qq(<span\nclass="q">);
+                       $$rv .= $l->to_html($cur);
+                       $$rv .= '</span>';
                } elsif ($diff) {
-                       flush_diff($rv, $ctx, \$cur);
+                       flush_diff($ctx, \$cur);
                } else {
                        # regular lines, OK
                        $$rv .= $l->to_html($cur);
-                       $cur = undef;
                }
+               undef $cur; # free memory
        }
-
-       obfuscate_addrs($ibx, $$rv) if $ibx->{obfuscate};
 }
 
 sub _msg_page_prepare_obuf {