]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Reply.pm
treewide: update to v3 Tor onions
[public-inbox.git] / lib / PublicInbox / Reply.pm
index 0f6dd83bc3f5e3db9716cdce58f93d701dcdfd1f..79dd46a729dd82be103647b0cf842443b3e4fc97 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2014-2018 all contributors <meta@public-inbox.org>
+# Copyright (C) 2014-2021 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
 # For reply instructions and address generation in WWW UI
@@ -6,18 +6,12 @@ package PublicInbox::Reply;
 use strict;
 use warnings;
 use URI::Escape qw/uri_escape_utf8/;
-use PublicInbox::Hval qw/ascii_html obfuscate_addrs/;
+use PublicInbox::Hval qw(ascii_html obfuscate_addrs mid_href);
 use PublicInbox::Address;
-use PublicInbox::MID qw/mid_clean mid_escape/;
+use PublicInbox::MID qw(mid_clean);
+use PublicInbox::Config;
 
-sub squote_maybe ($) {
-       my ($val) = @_;
-       if ($val =~ m{([^\w@\./,\%\+\-])}) {
-               $val =~ s/(['!])/'\\$1'/g; # '!' for csh
-               return "'$val'";
-       }
-       $val;
-}
+*squote_maybe = \&PublicInbox::Config::squote_maybe;
 
 sub add_addrs {
        my ($to, $cc, @addrs) = @_;
@@ -74,9 +68,10 @@ sub mailto_arg_link {
        my $obfs = $ibx->{obfuscate};
        my $subj = $hdr->header('Subject') || '';
        $subj = "Re: $subj" unless $subj =~ /\bRe:/i;
+       my $subj_raw = $subj;
        my $mid = $hdr->header_raw('Message-ID');
        push @arg, '--in-reply-to='.squote_maybe(mid_clean($mid));
-       my $irt = mid_escape($mid);
+       my $irt = mid_href($mid);
        delete $cc->{$to};
        if ($obfs) {
                my $arg_to = $to;
@@ -103,6 +98,8 @@ sub mailto_arg_link {
                }
        }
 
+       push @arg, "--subject=".squote_maybe($subj_raw);
+
        # I'm not sure if address obfuscation and mailto: links can
        # be made compatible; and address obfuscation is misguided,
        # anyways.