Double utf bug in RT 3.6.0 and some old versions

Hi there,

For ppl who have problems with national charactes in subject (koi8r, etc).

  1. fixing email subject encoding for corspond/comments.
  2. fixing email subject encoding via Templates “Subject:” keyword.

ps. dont sure about second patch, maybe it was broke something else :wink:

— cut here —
diff -ru /root/src/rt-3.6.0/lib/RT/I18N.pm lib/RT/I18N.pm
— /root/src/rt-3.6.0/lib/RT/I18N.pm 2006-01-19 18:11:21.000000000 +0300
+++ lib/RT/I18N.pm 2006-06-30 18:35:11.000000000 +0400
@@ -315,11 +315,13 @@

    # now we have got a decoded subject, try to convert into the encoding
    unless ($charset eq $enc) {
  •        Encode::_utf8_off($enc_str);
          eval { Encode::from_to($enc_str, $charset,  $enc) };
          if ($@) {
       $charset = _GuessCharset( $enc_str );
       Encode::from_to($enc_str, $charset, $enc);
          }
    
  •        Encode::_utf8_on($enc_str);
      }
    
       # XXX TODO: RT doesn't currently do the right thing with mime-encoded headers
    

— cut here —

— cut here —
diff -ru /root/src/rt-3.6.0/lib/RT/Template_Overlay.pm lib/RT/Template_Overlay.pm
— /root/src/rt-3.6.0/lib/RT/Template_Overlay.pm 2006-01-19 18:11:21.000000000 +0300
+++ lib/RT/Template_Overlay.pm 2006-06-30 18:53:03.000000000 +0400
@@ -391,7 +391,7 @@
return ( undef, $self->loc(‘Template parsing error’) ) if $is_broken;

 # MIME::Parser has problems dealing with high-bit utf8 data.
  • Encode::_utf8_off($retval);
    +# Encode::_utf8_off($retval);
    return ($retval);
    }
    — cut here —

Signed,
Dmitriy Kozlov
System, Network & Security Analyst
Elvis-Telecom, +7 495 7774308