From: cjwatson <>
Date: Fri, 21 Mar 2003 12:26:43 +0000 (-0800)
Subject: [project @ 2003-03-21 04:26:43 by cjwatson]
X-Git-Tag: release/2.6.0~942
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=b3557bc457ee50333c660c772032f9b7ed540dfd;p=debbugs.git

[project @ 2003-03-21 04:26:43 by cjwatson]
Turn forwarded-to address into a link if it looks like it's in fact a URL.
---

diff --git a/cgi/bugreport.cgi b/cgi/bugreport.cgi
index 9b4df6ac..35ff2697 100755
--- a/cgi/bugreport.cgi
+++ b/cgi/bugreport.cgi
@@ -121,7 +121,7 @@ if (@merged) {
 if (length($status{done})) {
 	push @descstates, "<strong>Done:</strong> ".htmlsanit($status{done});
 } elsif (length($status{forwarded})) {
-	push @descstates, "<strong>Forwarded</strong> to ".htmlsanit($status{forwarded});
+	push @descstates, "<strong>Forwarded</strong> to ".maybelink($status{forwarded});
 }
 
 $indexentry .= join(";\n", @descstates) . ";\n<br>" if @descstates;
diff --git a/cgi/common.pl b/cgi/common.pl
index 202d0c92..303d317c 100644
--- a/cgi/common.pl
+++ b/cgi/common.pl
@@ -176,7 +176,7 @@ sub htmlindexentrystatus {
     } else {
         if (length($status{forwarded})) {
             $result .= ";\n<strong>Forwarded</strong> to "
-                       . htmlsanit($status{forwarded});
+                       . maybelink($status{forwarded});
         }
         my $daysold = int((time - $status{date}) / 86400);   # seconds to days
         if ($daysold >= 7) {
@@ -255,6 +255,15 @@ sub htmlsanit {
     return $in;
 }
 
+sub maybelink {
+    my $in = shift;
+    if ($in =~ /^[a-zA-Z0-9+.-]+:/) { # RFC 1738 scheme
+	return qq{<a href="$in">} . htmlsanit($in) . '</a>';
+    } else {
+	return htmlsanit($in);
+    }
+}
+
 sub bugurl {
     my $ref = shift;
     my $params = "bug=$ref";