summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorterry%netscape.com <>1999-03-26 11:34:12 +0100
committerterry%netscape.com <>1999-03-26 11:34:12 +0100
commit5e0915466c15ea7e55e691d19d4d023933f3be6a (patch)
treec78ff8a9099fe5e84125c5ed538d9ab812cf7351
parent1885150ec2f834ac6eca117e2d422cba518d30f3 (diff)
downloadbugzilla-5e0915466c15ea7e55e691d19d4d023933f3be6a.tar.gz
bugzilla-5e0915466c15ea7e55e691d19d4d023933f3be6a.tar.xz
Redo the linkifying of URLs and email addresses to not munge up weird
cases so badly.
-rw-r--r--CHANGES7
-rw-r--r--README9
-rw-r--r--bug_form.pl59
3 files changed, 62 insertions, 13 deletions
diff --git a/CHANGES b/CHANGES
index 961b9682f..68ced886d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -10,10 +10,11 @@ query the CVS tree. For example,
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
-requires the use of the HTML::FromText CPAN module, which can be downloaded
-from ftp://ftp.cpan.org/pub/perl/CPAN/modules/by-module/HTML/.
+3/25/99 Unfortunately, the HTML::FromText CPAN module had too many bugs, and
+so I had to roll my own. We no longer use the HTML::FromText CPAN module.
+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
range. To make this perform a bit better, we need a new index:
diff --git a/README b/README
index 30c5c0cb6..8aab09394 100644
--- a/README
+++ b/README
@@ -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
listed in Appendix A.
-1.9. HTML::FromText Perl module (1.001 or greater)
-
-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
+1.9. HTTP server
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
@@ -375,8 +370,6 @@ GD Perl module: ftp://ftp.cpan.org/pub/perl/CPAN/modules/by-module/GD/
Chart::Base module:
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
diff --git a/bug_form.pl b/bug_form.pl
index e8bc30ec3..360c55bbc 100644
--- a/bug_form.pl
+++ b/bug_form.pl
@@ -21,7 +21,62 @@
use diagnostics;
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();
@@ -309,7 +364,7 @@ print "
<HR>
<PRE>
";
-print text2html($bug{'long_desc'}, email=>1, urls=>1);
+print quoteUrls($bug{'long_desc'}, email=>1, urls=>1);
print "
</PRE>
<HR>\n";