user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH] view: do not redundantly obfuscate addresses
@ 2020-04-06  8:32 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2020-04-06  8:32 UTC (permalink / raw)
  To: meta

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 | 2 +-
 lib/PublicInbox/View.pm | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/PublicInbox/Hval.pm b/lib/PublicInbox/Hval.pm
index 79005d21..23233f0e 100644
--- a/lib/PublicInbox/Hval.pm
+++ b/lib/PublicInbox/Hval.pm
@@ -78,7 +78,7 @@ sub prurl ($$) {
 # However, • was chosen to make copy+paste errors more obvious
 sub obfuscate_addrs ($$;$) {
 	my $ibx = $_[0];
-	my $repl = $_[2] || '•';
+	my $repl = $_[2] // '•';
 	my $re = $ibx->{-no_obfuscate_re}; # regex of domains
 	my $addrs = $ibx->{-no_obfuscate}; # { adddress => 1 }
 	$_[1] =~ s/(([\w\.\+=\-]+)\@([\w\-]+\.[\w\.\-]+))/
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index ddd94e48..33b323dc 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -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 `•' 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 {

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

only message in thread, other threads:[~2020-04-06  8:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-06  8:32 [PATCH] view: do not redundantly obfuscate addresses Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

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