]> git.donarmstrong.com Git - debbugs.git/commitdiff
[project @ 2005-04-09 16:21:02 by cjwatson]
authorcjwatson <>
Sat, 9 Apr 2005 23:21:02 +0000 (15:21 -0800)
committercjwatson <>
Sat, 9 Apr 2005 23:21:02 +0000 (15:21 -0800)
Decode RFC1522 mail headers for display in the web interface. bugreport.cgi
and pkgreport.cgi now output UTF-8.

This introduces .summary format version 3, in which all metadata is stored
in UTF-8. Due to a lack of testing and no migration script, this is not yet
the default. When reading/writing earlier format versions, RFC1522 metadata
is automatically decoded/encoded.

cgi/bugreport.cgi
cgi/common.pl
cgi/pkgreport.cgi
debian/changelog
scripts/errorlib.in
scripts/process.in
scripts/service.in

index 324b4a15a10ad905e577b1f89eb22649f51f7035..166d2d821eab3a441f6637e856c5f55fecfbb4e1 100755 (executable)
@@ -43,7 +43,7 @@ set_option('repeatmerged', $repeatmerged);
 my $buglog = buglog($ref);
 
 if ($ENV{REQUEST_METHOD} eq 'HEAD' and not defined($att) and not $mbox) {
-    print "Content-Type: text/html\n";
+    print "Content-Type: text/html; charset=utf-8\n";
     my @stat = stat $buglog;
     if (@stat) {
        my $mtime = strftime '%a, %d %b %Y %T GMT', gmtime($stat[9]);
@@ -70,7 +70,8 @@ sub display_entity ($$$$\$\@) {
     $filename = '' unless defined $filename;
 
     if ($top) {
-       $$this .= htmlsanit($entity->stringify_header) unless ($terse);
+       $$this .= htmlsanit(decode_rfc1522($entity->stringify_header))
+           unless ($terse);
        $$this .= "\n";
     }
 
@@ -150,7 +151,7 @@ $tail_html =~ s/SUBSTITUTE_DTIME/$dtime/;
 my %status = %{getbugstatus($ref)};
 unless (%status) {
     print <<EOF;
-Content-Type: text/html
+Content-Type: text/html; charset=utf-8
 
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
@@ -448,7 +449,7 @@ if ( $mbox ) {
        print join("", @mails );
        exit 0;
 }
-print "Content-Type: text/html\n\n";
+print "Content-Type: text/html; charset=utf-8\n\n";
 
 my $title = htmlsanit($status{subject});
 
index 18b60cd492411a2f9102f5647716eedf51d05175..2c0bf94501625e87b50622ce2bc86c520c4e7275 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;
 
index 0b98106853cfe34ed20dee70468ce02c647444ff..1955c4fd2d4d4b17f54e0e3edc6e40c370880be5 100755 (executable)
@@ -14,7 +14,7 @@ require '/etc/debbugs/text';
 use vars qw($gPackagePages $gWebDomain);
 
 if (defined $ENV{REQUEST_METHOD} and $ENV{REQUEST_METHOD} eq 'HEAD') {
-    print "Content-Type: text/html\n\n";
+    print "Content-Type: text/html; charset=utf-8\n\n";
     exit 0;
 }
 
@@ -234,7 +234,7 @@ if (defined $pkg) {
 
 my $result = htmlizebugs(\@bugs);
 
-print "Content-Type: text/html\n\n";
+print "Content-Type: text/html; charset=utf-8\n\n";
 
 print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
 print "<HTML><HEAD>\n" . 
index 2182a1569287eaa020aec434d49a6c299e2f22f6..e1b25e454a7d8459884e6c354904baee1be627d7 100644 (file)
@@ -23,6 +23,8 @@ debbugs (2.4.2) UNRELEASED; urgency=low
     - Add X-$gProject-PR-Message: headers to all mails sent by service.
     - debbugsconfig creates required directories in $gSpoolDir
       (closes: #222077).
+    - Decode RFC1522 mail headers for display in the web interface.
+      bugreport.cgi and pkgreport.cgi now output UTF-8.
 
   * Adam Heath:
     - Rewrite filtering in cgi's common.pl, to make it completely generic.
index 63fa332734f2ccd4d31889a25ebd44f533af137e..cdf18557e7db8176727517be3bc442c600900627 100755 (executable)
@@ -1,7 +1,8 @@
 # -*- perl -*-
-# $Id: errorlib.in,v 1.41 2004/02/15 16:12:00 cjwatson Exp $
+# $Id: errorlib.in,v 1.42 2005/04/09 16:21:02 cjwatson Exp $
 
 use Mail::Address;
+use Debbugs::MIME qw(decode_rfc1522 encode_rfc1522);
 
 sub F_SETLK { 6; } sub F_WRLCK{ 1; }
 $flockstruct= 'sslll'; # And there ought to be something for this too.
@@ -86,6 +87,9 @@ my %fields = (originator => 'submitter',
               owner => 'owner',
              );
 
+# Fields which need to be RFC1522-decoded in format versions earlier than 3.
+my @rfc1522_fields = qw(originator subject done forwarded owner);
+
 sub readbug {
     my ($lref, $location) = @_;
     my $status = getbugcomponent($lref, 'summary', $location);
@@ -103,8 +107,8 @@ sub readbug {
         $version = $1 if /^Format-Version: ([0-9]+)/i;
     }
 
-    # Version 2 is the latest format version currently supported.
-    return undef if $version > 2;
+    # Version 3 is the latest format version currently supported.
+    return undef if $version > 3;
 
     my %namemap = reverse %fields;
     for my $line (@lines) {
@@ -121,6 +125,12 @@ sub readbug {
 
     $data{severity} = 'normal' if $data{severity} eq '';
 
+    if ($version < 3) {
+       for my $field (@rfc1522_fields) {
+           $data{$field} = decode_rfc1522($data{$field});
+       }
+    }
+
     return \%data;
 }
 
@@ -139,24 +149,31 @@ sub makestatus {
 
     my $contents = '';
 
+    my %newdata = %$data;
+    if ($version < 3) {
+        for my $field (@rfc1522_fields) {
+            $newdata{$field} = encode_rfc1522($newdata{$field});
+        }
+    }
+
     if ($version == 1) {
         for my $field (@v1fieldorder) {
-            if (exists $data->{$field}) {
-                $contents .= "$data->{$field}\n";
+            if (exists $newdata{$field}) {
+                $contents .= "$newdata{$field}\n";
             } else {
                 $contents .= "\n";
             }
         }
-    } elsif ($version == 2) {
-        # Version 2. Add a file format version number for the sake of
+    } elsif ($version == 2 or $version == 3) {
+        # Version 2 or 3. Add a file format version number for the sake of
         # further extensibility in the future.
-        $contents .= "Format-Version: 2\n";
+        $contents .= "Format-Version: $version\n";
         for my $field (keys %fields) {
-            if (exists $data->{$field} and $data->{$field} ne '') {
+            if (exists $newdata{$field} and $newdata{$field} ne '') {
                 # Output field names in proper case, e.g. 'Merged-With'.
                 my $properfield = $fields{$field};
                 $properfield =~ s/(?:^|(?<=-))([a-z])/\u$1/g;
-                $contents .= "$properfield: $data->{$field}\n";
+                $contents .= "$properfield: $newdata{$field}\n";
             }
         }
     }
index d4bf80653b2e03791d6c2221d23fadccd8d03eeb..a5cdf4d719b4c793967854b4653a9ca5a4b0cde6 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-# $Id: process.in,v 1.88 2005/01/02 19:08:12 cjwatson Exp $
+# $Id: process.in,v 1.89 2005/04/09 16:21:02 cjwatson Exp $
 #
 # Usage: process nn
 # Temps:  incoming/Pnn
@@ -9,6 +9,7 @@ $ENV{"TZ"} = 'UTC';
 tzset();
 
 use MIME::Parser;
+use Debbugs::MIME qw(decode_rfc1522);
 
 $config_path = '/etc/debbugs';
 $lib_path = '/usr/lib/debbugs';
@@ -108,7 +109,7 @@ for my $hdr (@headerlines) {
     if (s/^(\S+):\s*//) {
        my $v = lc $1;
        print DEBUG ">$v=$_<\n";
-       $header{$v} = $_;
+       $header{$v} = decode_rfc1522($_);
     } else {
        print DEBUG "!>$_<\n";
     }
index 24e9d996c2f172d530784596da90ef5e0e0ba0e0..8361b9fceb2c5c6079fb3016e4b12b15b51f536e 100755 (executable)
@@ -1,11 +1,12 @@
 #!/usr/bin/perl
-# $Id: service.in,v 1.98 2005/03/15 21:40:41 cjwatson Exp $
+# $Id: service.in,v 1.99 2005/04/09 16:21:02 cjwatson Exp $
 #
 # Usage: service <code>.nn
 # Temps:  incoming/P<code>.nn
 
 use File::Copy;
 use MIME::Parser;
+use Debbugs::MIME qw(decode_rfc1522);
 
 $config_path = '/etc/debbugs';
 $lib_path = '/usr/lib/debbugs';
@@ -76,7 +77,7 @@ for (@headerlines) {
     if (s/^(\S+):\s*//) {
        my $v = lc $1;
        print ">$v=$_<\n" if $debug;
-       $header{$v} = $_;
+       $header{$v} = decode_rfc1522($_);
     } else {
        print "!>$_<\n" if $debug;
     }