]> git.donarmstrong.com Git - debbugs.git/blobdiff - Debbugs/MIME.pm
properly encode utf8 status fields when version is 3
[debbugs.git] / Debbugs / MIME.pm
index 95dafb8dc5075ed9a515143c00dd8e584e653bb0..640627651581826bf8bcce5570d8acb46085a3ce 100644 (file)
@@ -286,10 +286,15 @@ sub encode_rfc1522 {
 
      # handle being passed undef properly
      return undef if not defined $rawstr;
+     if (is_utf8($rawstr)) {
+        $rawstr= encode_utf8($rawstr);
+     }
      # We process words in reverse so we can preserve spacing between
      # encoded words. This regex splits on word|nonword boundaries and
-     # nonword|nonword boundaries.
-     my @words = reverse split /(?:(?<=[\s\n])|(?=[\s\n]))/m, $rawstr;
+     # nonword|nonword boundaries. We also consider parenthesis and "
+     # to be nonwords to avoid escaping them in comments in violation
+     # of RFC1522
+     my @words = reverse split /(?:(?<=[\s\n\)\(\"])|(?=[\s\n\)\(\"]))/m, $rawstr;
 
      my $previous_word_encoded = 0;
      my $string = '';