]> git.donarmstrong.com Git - debbugs.git/blobdiff - cgi/common.pl
[project @ 2005-05-11 09:52:23 by cjwatson]
[debbugs.git] / cgi / common.pl
index 18b60cd492411a2f9102f5647716eedf51d05175..db9d1f4dd7ee096a9927ca5bdc5b69bbf52b0a02 100644 (file)
@@ -11,6 +11,7 @@ $lib_path = '/usr/lib/debbugs';
 require "$lib_path/errorlib";
 
 use Debbugs::Versions;
+use Debbugs::MIME qw(decode_rfc1522);
 
 $MLDBM::RemoveTaint = 1;
 
@@ -243,25 +244,34 @@ sub htmlpackagelinks {
            ) . ";\n";
 }
 
-# Generate a comma-separated list of HTML links to each maintainer given in
-# $maints, which should be a comma-separated list of RFC822 addresses.
-sub htmlmaintlinks {
-    my ($prefixfunc, $maints) = @_;
-    if (defined $maints and $maints ne '') {
-        my @maintaddrs = getparsedaddrs($maints);
-        my $prefix = (ref $prefixfunc) ? $prefixfunc->(scalar @maintaddrs)
+# Generate a comma-separated list of HTML links to each address given in
+# $addresses, which should be a comma-separated list of RFC822 addresses.
+# $urlfunc should be a reference to a function like mainturl or submitterurl
+# which returns the URL for each individual address.
+sub htmladdresslinks {
+    my ($prefixfunc, $urlfunc, $addresses) = @_;
+    if (defined $addresses and $addresses ne '') {
+        my @addrs = getparsedaddrs($addresses);
+        my $prefix = (ref $prefixfunc) ? $prefixfunc->(scalar @addrs)
                                        : $prefixfunc;
         return $prefix .
                join ', ', map { sprintf '<a href="%s">%s</a>',
-                                        mainturl($_->address),
+                                        $urlfunc->($_->address),
                                         htmlsanit($_->format) || '(unknown)'
-                              } @maintaddrs;
+                              } @addrs;
     } else {
         my $prefix = (ref $prefixfunc) ? $prefixfunc->(1) : $prefixfunc;
-        return sprintf '%s<a href="%s">(unknown)</a>', $prefix, mainturl('');
+        return sprintf '%s<a href="%s">(unknown)</a>', $prefix, $urlfunc->('');
     }
 }
 
+# Generate a comma-separated list of HTML links to each maintainer given in
+# $maints, which should be a comma-separated list of RFC822 addresses.
+sub htmlmaintlinks {
+    my ($prefixfunc, $maints) = @_;
+    return htmladdresslinks($prefixfunc, \&mainturl, $maints);
+}
+
 sub htmlindexentry {
     my $ref = shift;
     my %status = %{getbugstatus($ref)};
@@ -285,8 +295,8 @@ sub htmlindexentrystatus {
 
     $result .= htmlpackagelinks($status{"package"}, 1);
     $result .= $showseverity;
-    $result .= "Reported by: <a href=\"" . submitterurl($status{originator})
-               . "\">" . htmlsanit($status{originator}) . "</a>";
+    $result .= htmladdresslinks("Reported by: ", \&submitterurl,
+                                $status{originator});
     $result .= ";\nOwned by: " . htmlsanit($status{owner})
                if length $status{owner};
     $result .= ";\nTags: <strong>"