]> Sergey Matveev's repositories - public-inbox.git/commitdiff
reply: follow obfuscation rules for HTML in sh args
authorEric Wong <e@80x24.org>
Mon, 29 Jan 2018 13:04:09 +0000 (13:04 +0000)
committerEric Wong <e@80x24.org>
Mon, 29 Jan 2018 13:09:05 +0000 (13:09 +0000)
Namely, we do not want to obfuscate the mail address of the
site itself.

lib/PublicInbox/Hval.pm
lib/PublicInbox/Reply.pm

index 0e199025adcec36d72d55e139900e1bf03f26edc..d65ab3217c915a18db892e226a87af7594a2fe53 100644 (file)
@@ -91,8 +91,9 @@ sub prurl {
 # &#8228; &#183; and &#890; were also candidates:
 #   https://public-inbox.org/meta/20170615015250.GA6484@starla/
 # However, &#8226; was chosen to make copy+paste errors more obvious
-sub obfuscate_addrs ($$) {
+sub obfuscate_addrs ($$;$) {
        my $ibx = $_[0];
+       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\.\-]+))/
@@ -100,7 +101,7 @@ sub obfuscate_addrs ($$) {
                if ($addrs->{$addr} || ((defined $re && $domain =~ $re))) {
                        $addr;
                } else {
-                       $domain =~ s!([^\.]+)\.!$1&#8226;!;
+                       $domain =~ s!([^\.]+)\.!$1$repl!;
                        $user . '@' . $domain
                }
                /sge;
index 07288aab3c4fd21f34df3f28cb416144242cecb3..eee41173562d37161defd376d02f94357b56b568 100644 (file)
@@ -4,7 +4,7 @@ package PublicInbox::Reply;
 use strict;
 use warnings;
 use URI::Escape qw/uri_escape_utf8/;
-use PublicInbox::Hval qw/ascii_html/;
+use PublicInbox::Hval qw/ascii_html obfuscate_addrs/;
 use PublicInbox::Address;
 use PublicInbox::MID qw/mid_clean mid_escape/;
 
@@ -70,8 +70,9 @@ sub mailto_arg_link {
        delete $cc->{$to};
        if ($obfs) {
                my $arg_to = $to;
-               $arg_to =~ s/\./\$(echo .)/;
+               obfuscate_addrs($ibx, $arg_to, '$(echo .)');
                push @arg, "--to=$arg_to";
+               # no $subj for $href below
        } else {
                push @arg, "--to=$to";
                $to = uri_escape_utf8($to);
@@ -82,8 +83,9 @@ sub mailto_arg_link {
        if (@cc) {
                if ($obfs) {
                        push(@arg, map {
-                               s/\./\$(echo .)/;
-                               "--cc=$_";
+                               my $addr = $_;
+                               obfuscate_addrs($ibx, $addr, '$(echo .)');
+                               "--cc=$addr";
                        } @cc);
                } else {
                        $cc = '&Cc=' . uri_escape_utf8(join(',', @cc));