]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Redo the linkifying of URLs and email addresses to not munge up weird
authorterry%netscape.com <>
Fri, 26 Mar 1999 10:34:12 +0000 (10:34 +0000)
committerterry%netscape.com <>
Fri, 26 Mar 1999 10:34:12 +0000 (10:34 +0000)
cases so badly.

CHANGES
README
bug_form.pl

diff --git a/CHANGES b/CHANGES
index 961b9682ff7eaba9e2350046ef0f91ec7a7a6b6c..68ced886d034c8180e326dfa6ebddc20d54c702c 100644 (file)
--- 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 30c5c0cb6c54f5da32e00b75b52ad7975a4c038d..8aab09394d08898903a6e5d89682e317fe389312 100644 (file)
--- 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
 
index e8bc30ec3fba47de67f66a6661d9d9808cdf43f6..360c55bbcacea29bfb67580c7e384b3ee3926de8 100644 (file)
 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";