Commit 5e091546 authored by terry%netscape.com's avatar terry%netscape.com

Redo the linkifying of URLs and email addresses to not munge up weird

cases so badly.
parent 1885150e
...@@ -10,10 +10,11 @@ query the CVS tree. For example, ...@@ -10,10 +10,11 @@ query the CVS tree. For example,
will tell you what has been changed in the last week. will tell you what has been changed in the last week.
3/24/99 Added quoting of URLs and email addresses in bug descriptions. This 3/25/99 Unfortunately, the HTML::FromText CPAN module had too many bugs, and
requires the use of the HTML::FromText CPAN module, which can be downloaded so I had to roll my own. We no longer use the HTML::FromText CPAN module.
from ftp://ftp.cpan.org/pub/perl/CPAN/modules/by-module/HTML/.
3/24/99 (This entry has been removed. It used to say that we required the
HTML::FromText CPAN module, but that's no longer true.)
3/22/99 Added the ability to query by fields which have changed within a date 3/22/99 Added the ability to query by fields which have changed within a date
range. To make this perform a bit better, we need a new index: range. To make this perform a bit better, we need a new index:
......
...@@ -161,12 +161,7 @@ It can be installed in the usual fashion after it has been fetched from ...@@ -161,12 +161,7 @@ It can be installed in the usual fashion after it has been fetched from
CPAN where it is found as the Chart-x.x... tarball in a directory to be CPAN where it is found as the Chart-x.x... tarball in a directory to be
listed in Appendix A. listed in Appendix A.
1.9. HTML::FromText Perl module (1.001 or greater) 1.9. HTTP server
This module does conversion from plaintext to html, doing the right
things with URLs and stuff. You can find it on CPAN (link in Appendix A).
1.10. HTTP server
You have a freedom of choice here - Apache, Netscape or any other server on You have a freedom of choice here - Apache, Netscape or any other server on
UNIX would do. The only thing - to make configuration easier you'd better run UNIX would do. The only thing - to make configuration easier you'd better run
...@@ -375,8 +370,6 @@ GD Perl module: ftp://ftp.cpan.org/pub/perl/CPAN/modules/by-module/GD/ ...@@ -375,8 +370,6 @@ GD Perl module: ftp://ftp.cpan.org/pub/perl/CPAN/modules/by-module/GD/
Chart::Base module: Chart::Base module:
ftp://ftp.cpan.org/pub/perl/CPAN/modules/by-module/Chart/ ftp://ftp.cpan.org/pub/perl/CPAN/modules/by-module/Chart/
HTML::FromText module:
ftp://ftp.cpan.org/pub/perl/CPAN/modules/by-module/HTML/
Appendix B. Modifying Your Running System Appendix B. Modifying Your Running System
......
...@@ -21,7 +21,62 @@ ...@@ -21,7 +21,62 @@
use diagnostics; use diagnostics;
use strict; use strict;
use HTML::FromText;
# This routine quoteUrls contains inspirations from the HTML::FromText CPAN
# module by Gareth Rees <garethr@cre.canon.co.uk>. It has been heavily hacked,
# all that is really recognizable from the original is bits of the regular
# expressions.
sub quoteUrls {
my $text = shift; # Take a copy; don't modify in-place.
return $text unless $text;
my $protocol = join '|',
qw(afs cid ftp gopher http https mid news nntp prospero telnet wais);
my %options = ( metachars => 1, @_ );
my $count = 0;
# Now, quote any "#" characters so they won't confuse stuff later
$text =~ s/#/%#/g;
# Next, find anything that looks like a URL or an email address and
# pull them out the the text, replacing them with a "##<digits>##
# marker, and writing them into an array. All this confusion is
# necessary so that we don't match on something we've already replaced,
# which can happen if you do multiple s///g operations.
my @things;
while ($text =~ s%((mailto:)?([\w\.\-\+\=]+\@\w+(?:\.\w+)+)\b|
(\b((?:$protocol):\S+[\w/])))%"##".$count."##"%exo) {
my $item = $&;
$item = value_quote($item);
if ($item !~ m/^$protocol:/o && $item !~ /^mailto:/) {
# We must have grabbed this one because it looks like an email
# address.
$item = qq{<A HREF="mailto:$item">$item</A>};
} else {
$item = qq{<A HREF="$item">$item</A>};
}
$things[$count++] = $item;
}
$text = value_quote($text);
# Stuff everything back from the array.
for (my $i=0 ; $i<$count ; $i++) {
$text =~ s/##$i##/$things[$i]/e;
}
# And undo the quoting of "#" characters.
$text =~ s/%#/#/g;
return $text;
}
quietly_check_login(); quietly_check_login();
...@@ -309,7 +364,7 @@ print " ...@@ -309,7 +364,7 @@ print "
<HR> <HR>
<PRE> <PRE>
"; ";
print text2html($bug{'long_desc'}, email=>1, urls=>1); print quoteUrls($bug{'long_desc'}, email=>1, urls=>1);
print " print "
</PRE> </PRE>
<HR>\n"; <HR>\n";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment