[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#61342: your mail



tbm brought to my attention another bug that should be fixed, namely
the maintainer e-mail address that is sent out when someone closes the
bug:

http://bugs.donarmstrong.com/cgi/bugreport.cgi?bug=18&msg=12

The patch now has moved the de_rfc1522 code into Debbugs::MIME since
this slice of code needs to be used in both the cgi scripts and the
process script.

I've also taken the liberty of cleaning up the way that Exporter is
used, and replaced munging with @ISA with a straightforward use base
'Exporter';


Don Armstrong

-- 
I leave the show floor, but not before a pack of caffeinated Jolt gum
is thrust at me by a hyperactive girl screaming, "Chew more! Do more!"
The American will to consume more and produce more personified in a
stick of gum. I grab it. -- Chad Dickerson

http://www.donarmstrong.com              http://rzlab.ucr.edu
Index: Debbugs/MIME.pm
===================================================================
RCS file: /cvs/debbugs/source/Debbugs/MIME.pm,v
retrieving revision 1.1
diff -u -r1.1 MIME.pm
--- Debbugs/MIME.pm	3 Aug 2003 09:46:30 -0000	1.1
+++ Debbugs/MIME.pm	11 Jan 2005 16:43:49 -0000
@@ -2,19 +2,23 @@
 
 use strict;
 
-use File::Path;
-use MIME::Parser;
-use Exporter ();
-use vars qw($VERSION @ISA @EXPORT_OK);
+use base qw(Exporter);
+use vars qw($VERSION @EXPORT_OK @EXPORT);
 
 BEGIN {
     $VERSION = 1.00;
 
-    @ISA = qw(Exporter);
-    @EXPORT_OK = qw(parse);
+    @EXPORT_OK = qw(parse de_rfc1522 getmailbody);
+    @EXPORT = qw(getmailbody);
 }
 
-sub getmailbody ($);
+use File::Path;
+use MIME::Parser;
+
+# for de_rfc1522
+use MIME::WordDecoder qw();
+use Unicode::MapUTF8 qw(to_utf8 utf8_supported_charset);
+
 sub getmailbody ($)
 {
     my $entity = shift;
@@ -95,5 +99,33 @@
 
     return { header => [@headerlines], body => [@bodylines]};
 }
+
+=head2 de_rfc1522
+
+     de_rfc1522('=?iso-8859-1?Q?D=F6n_Armstr=F3ng?= <don@donarmstrong.com>')
+
+Turn RFC-1522 names into the UTF-8 equivalent. [#61342 et al]
+
+=cut
+
+# Set up the default rfc1522 decoder, which turns all charsets that
+# are supported into the appropriate UTF-8 charset.
+MIME::WordDecoder->default(new MIME::WordDecoder(['*' => sub {my ($data,$charset) = @_;
+							      $charset =~ s/^(UTF)\-(\d+)/$1$2/i;
+							      return $data unless utf8_supported_charset($charset);
+							      return to_utf8({-string  => $data,
+									      -charset => $charset,
+									     });
+							 },
+						 ],));
+
+sub de_rfc1522($){
+     my ($string) = @_;
+
+     # unmime calls the default MIME::WordDecoder; handler set up at
+     # initalization time.
+     return MIME::WordDecoder::unmime($string);
+}
+
 
 1;
Index: cgi/bugreport.cgi
===================================================================
RCS file: /cvs/debbugs/source/cgi/bugreport.cgi,v
retrieving revision 1.65
diff -u -r1.65 bugreport.cgi
--- cgi/bugreport.cgi	1 Jun 2004 00:41:26 -0000	1.65
+++ cgi/bugreport.cgi	11 Jan 2005 16:43:49 -0000
@@ -70,7 +70,7 @@
     $filename = '' unless defined $filename;
 
     if ($top) {
-	$$this .= htmlsanit($entity->stringify_header) unless ($terse);
+	$$this .= htmlsanit(de_rfc1522($entity->stringify_header)) unless ($terse);
 	$$this .= "\n";
     }
 
@@ -150,7 +150,7 @@
 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>
@@ -181,7 +181,7 @@
 $indexentry .= htmlpackagelinks($status{package}, 0);
 
 $indexentry .= "Reported by: <a href=\"" . submitterurl($status{originator})
-              . "\">" . htmlsanit($status{originator}) . "</a>;\n";
+              . "\">" . htmlsanit(de_rfc1522($status{originator})) . "</a>;\n";
 
 $indexentry .= "Owned by: " . htmlsanit($status{owner}) . ";\n"
               if length $status{owner};
@@ -219,11 +219,11 @@
     $fixedtext .= (@{$status{fixed_versions}} == 1) ? 'version ' : 'versions ';
     $fixedtext .= join ', ', map htmlsanit($_), @{$status{fixed_versions}};
     if (length($status{done})) {
-	$fixedtext .= ' by ' . htmlsanit($status{done});
+	$fixedtext .= ' by ' . htmlsanit(de_rfc1522($status{done}));
     }
     push @descstates, $fixedtext;
 } elsif (length($status{done})) {
-	push @descstates, "<strong>Done:</strong> ".htmlsanit($status{done});
+	push @descstates, "<strong>Done:</strong> ".htmlsanit(de_rfc1522($status{done}));
 } elsif (length($status{forwarded})) {
 	push @descstates, "<strong>Forwarded</strong> to ".maybelink($status{forwarded});
 }
@@ -369,7 +369,9 @@
 		$normstate= 'go';
 		push @mail, $_;
 	} elsif ($normstate eq 'html') {
-		$this .= $_;
+	        # XXX This is broken. The BTS shouldn't be writing
+	        # HTML into the log... but it does.
+		$this .= de_rfc1522($_);
 	} elsif ($normstate eq 'go') {
 		s/^\030//;
 		if (!$suppressnext && !$found_msgid &&
@@ -409,7 +411,7 @@
 			$thisheader = "<h2>Message sent:</h2>\n";
 		} else {
 			s/\04/, /g; s/\n$//;
-			$thisheader = "<h2>Message sent to ".htmlsanit($_).":</h2>\n";
+			$thisheader = "<h2>Message sent to ".htmlsanit(de_rfc1522($_)).":</h2>\n";
 		}
 		$this = "";
 		$normstate= 'kill-body';
@@ -448,7 +450,7 @@
 	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: cgi/common.pl
===================================================================
RCS file: /cvs/debbugs/source/cgi/common.pl,v
retrieving revision 1.108
diff -u -r1.108 common.pl
--- cgi/common.pl	28 Mar 2004 06:02:45 -0000	1.108
+++ cgi/common.pl	11 Jan 2005 16:43:49 -0000
@@ -11,6 +11,7 @@
 require "$lib_path/errorlib";
 
 use Debbugs::Versions;
+use Debbugs::MIME qw(de_rfc1522);
 
 $MLDBM::RemoveTaint = 1;
 
@@ -286,8 +287,8 @@
     $result .= htmlpackagelinks($status{"package"}, 1);
     $result .= $showseverity;
     $result .= "Reported by: <a href=\"" . submitterurl($status{originator})
-               . "\">" . htmlsanit($status{originator}) . "</a>";
-    $result .= ";\nOwned by: " . htmlsanit($status{owner})
+               . "\">" . htmlsanit(de_rfc1522($status{originator})) . "</a>";
+    $result .= ";\nOwned by: " . htmlsanit(de_rfc1522($status{owner}))
                if length $status{owner};
     $result .= ";\nTags: <strong>" 
 		 . htmlsanit(join(", ", sort(split(/\s+/, $status{tags}))))
Index: cgi/pkgreport.cgi
===================================================================
RCS file: /cvs/debbugs/source/cgi/pkgreport.cgi,v
retrieving revision 1.76
diff -u -r1.76 pkgreport.cgi
--- cgi/pkgreport.cgi	19 Apr 2004 10:30:42 -0000	1.76
+++ cgi/pkgreport.cgi	11 Jan 2005 16:43:49 -0000
@@ -234,7 +234,7 @@
 
 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: scripts/process.in
===================================================================
RCS file: /cvs/debbugs/source/scripts/process.in,v
retrieving revision 1.86
diff -u -r1.86 process.in
--- scripts/process.in	5 Aug 2004 15:09:30 -0000	1.86
+++ scripts/process.in	11 Jan 2005 16:43:49 -0000
@@ -17,6 +17,9 @@
 require "$lib_path/errorlib";
 $ENV{'PATH'} = $lib_path.':'.$ENV{'PATH'};
 
+# for de_rfc1522
+use Debbugs::MIME qw(de_rfc1522);
+
 chdir( "$gSpoolDir" ) || die "chdir spool: $!\n";
 
 #open(DEBUG,"> /tmp/debbugs.debug");
@@ -252,6 +255,7 @@
     }
     $markedby= $header{'from'} eq $replyto ? $replyto :
                "$header{'from'} (reply to $replyto)";
+    $markedby = de_rfc1522($markedby);
     if ($codeletter eq 'F') {
         (&appendlog,&finish) if length($data->{forwarded});
         $receivedat= "forwarded\@$gEmailDomain";
@@ -430,6 +434,7 @@
 X-$gProject-PR-Package: $data->{package}
 X-$gProject-PR-Keywords: $data->{keywords}
 Reply-To: $ref\@$gEmailDomain
+Content-Type: text/plain; charset="utf-8"
 
 This is an automatic notification regarding your $gBug report
 #$ref: $data->{subject},

Attachment: signature.asc
Description: Digital signature


Reply to: