hyperlinks in mail archives don't deal with all special html characters properly

PR: www/45184
Submitted by: Dan Langille <dan@undef.unixathome.org>
This commit is contained in:
Wolfram Schneider 2003-03-11 15:22:52 +00:00
parent 9773938266
commit a74e3ae6d1
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/www/; revision=16254

View file

@ -6,7 +6,7 @@
# by John Fieber # by John Fieber
# February 26, 1998 # February 26, 1998
# #
# $FreeBSD: www/en/cgi/getmsg.cgi,v 1.33 2001/11/07 16:32:11 sobomax Exp $ # $FreeBSD: www/en/cgi/getmsg.cgi,v 1.34 2002/03/19 00:53:52 peter Exp $
# #
require "./cgi-lib.pl"; require "./cgi-lib.pl";
@ -205,12 +205,23 @@ sub MessageToHTML
return $message; return $message;
} }
sub strip_url
{
my $url = shift;
# strip trailing characters
$url =~ s/&gt;?$//;
$url =~ s/[.,;>\s]*$//;
return $url;
}
sub AddAnchors sub AddAnchors
{ {
my ($text) = @_; my ($text) = @_;
my $cvsweb = 'http://cvsweb.FreeBSD.org/'; my $cvsweb = 'http://cvsweb.FreeBSD.org/';
$text =~ s/(http|https|ftp|gopher|mailto|news|file)(:[^\s]*?\/?)(\W?\s)/<a href="$1$2">$1$2<\/a>$3/goi; $text =~ s/(http|https|ftp|gopher|mailto|news|file)(:[\S]*?\/?)(\W?\s)/sprintf("<a href=\"%s\">%s<\/a>$3", &strip_url("$1$2"), &strip_url("$1$2"), $3)/egoi;
if ($text =~ /Revision\s+Changes\s+Path/) { if ($text =~ /Revision\s+Changes\s+Path/) {