Add a simple filter to turn URL type things in to HTML anchors.

Improved URL detection patterns gladly accepted.
This commit is contained in:
John Fieber 1998-02-27 03:45:29 +00:00
parent 2944f9fd66
commit e912559710
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/www/; revision=2489
2 changed files with 24 additions and 4 deletions

View file

@ -6,7 +6,7 @@
# by John Fieber
# February 26, 1998
#
# $Id: getmsg.cgi,v 1.2 1998-02-27 02:56:26 jfieber Exp $
# $Id: getmsg.cgi,v 1.3 1998-02-27 03:45:29 jfieber Exp $
#
require "./cgi-lib.pl";
@ -74,7 +74,7 @@ sub MessageToHTML
my ($header, $body) = split(/\n\n/, $doc, 2);
my ($i, %hdr, $field, $data, $message);
$body = &EscapeHTML($body);
$body = &AddAnchors(&EscapeHTML($body));
$header = &EscapeHTML($header);
$header =~ s/\n */ /g;
@ -109,3 +109,13 @@ sub MessageToHTML
return $message;
}
sub AddAnchors
{
my ($text) = @_;
$text =~ s/(http|https|ftp|gopher|mailto|news|file)(:[^\s]*?\/?)(\W?\s)/<a href="$1$2">$1$2<\/a>$3/g;
return $text;
}

View file

@ -6,7 +6,7 @@
# by John Fieber
# February 26, 1998
#
# $Id: getmsg.cgi,v 1.2 1998-02-27 02:56:26 jfieber Exp $
# $Id: getmsg.cgi,v 1.3 1998-02-27 03:45:29 jfieber Exp $
#
require "./cgi-lib.pl";
@ -74,7 +74,7 @@ sub MessageToHTML
my ($header, $body) = split(/\n\n/, $doc, 2);
my ($i, %hdr, $field, $data, $message);
$body = &EscapeHTML($body);
$body = &AddAnchors(&EscapeHTML($body));
$header = &EscapeHTML($header);
$header =~ s/\n */ /g;
@ -109,3 +109,13 @@ sub MessageToHTML
return $message;
}
sub AddAnchors
{
my ($text) = @_;
$text =~ s/(http|https|ftp|gopher|mailto|news|file)(:[^\s]*?\/?)(\W?\s)/<a href="$1$2">$1$2<\/a>$3/g;
return $text;
}