X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FLinkify.pm;h=b85bedfed9aa6f3bfdf2102e2311b52c573b7786;hb=906393b801050e303d2ec2a660c85de4a5fa4740;hp=77b94f56af4fc104789ed76ce58483afbd98fd38;hpb=f09b01e0e89dbdf0f0bd6bfae2f8545fa17657d2;p=public-inbox.git
diff --git a/lib/PublicInbox/Linkify.pm b/lib/PublicInbox/Linkify.pm
index 77b94f56..b85bedfe 100644
--- a/lib/PublicInbox/Linkify.pm
+++ b/lib/PublicInbox/Linkify.pm
@@ -1,4 +1,4 @@
-# Copyright (C) 2014-2019 all contributors
+# Copyright (C) 2014-2020 all contributors
# License: AGPL-3.0+
# two-step linkification.
@@ -13,7 +13,8 @@ package PublicInbox::Linkify;
use strict;
use warnings;
use Digest::SHA qw/sha1_hex/;
-use PublicInbox::Hval qw(ascii_html);
+use PublicInbox::Hval qw(ascii_html mid_href);
+use PublicInbox::MID qw($MID_EXTRACT);
my $SALT = rand;
my $LINK_RE = qr{([\('!])?\b((?:ftps?|https?|nntps?|gopher)://
@@ -93,11 +94,10 @@ sub linkify_2 {
# with $pfx being the URL prefix
sub linkify_mids {
my ($self, $pfx, $str, $raw) = @_;
- $$str =~ s!<([^>]+)>!
- my $msgid = PublicInbox::Hval->new_msgid($1);
- my $html = $msgid->as_html;
- my $href = $msgid->{href};
- $href = ascii_html($href); # for IDN
+ $$str =~ s!$MID_EXTRACT!
+ my $mid = $1;
+ my $html = ascii_html($mid);
+ my $href = mid_href($mid);
# salt this, as this could be exploited to show
# links in the HTML which don't show up in the raw mail.
@@ -120,4 +120,6 @@ sub linkify_mids {
!ge;
}
+sub to_html { linkify_2($_[0], ascii_html(linkify_1(@_))) }
+
1;