-my $LINK_RE = qr!\b((?:ftp|https?|nntp)://
- [\@:\w\.-]+/
- ?[\@\w\+\&\?\.\%\;/#=-]*)!x;
-
-sub linkify_1 {
- my ($link_map, $s) = @_;
- $s =~ s!$LINK_RE!
- my $url = $1;
- # salt this, as this could be exploited to show
- # links in the HTML which don't show up in the raw mail.
- my $key = sha1_hex($url . $SALT);
- $link_map->{$key} = $url;
- 'PI-LINK-'. $key;
- !ge;
- $s;
-}
-
-sub linkify_2 {
- my ($link_map, $s) = @_;
-
- # Added "PI-LINK-" prefix to avoid false-positives on git commits
- $s =~ s!\bPI-LINK-([a-f0-9]{40})\b!
- my $key = $1;
- my $url = $link_map->{$key};
- if (defined $url) {
- $url = ascii_html($url);
- "<a\nhref=\"$url\">$url</a>";
- } else {
- # false positive or somebody tried to mess with us
- $key;
- }
- !ge;
- $s;
-}
-