This commit was generated by cvs2svn to compensate for changes in r6252,
[freeside.git] / rt / lib / RT / I18N.pm
index affff98..448f4a2 100644 (file)
@@ -223,7 +223,7 @@ sub SetMIMEEntityToEncoding {
 
        # {{{ Convert the body
        eval {
-           $RT::Logger->debug("Converting '$charset' to '$enc' for ". $head->mime_type . " - ". $head->get('subject'));
+           $RT::Logger->debug("Converting '$charset' to '$enc' for ". $head->mime_type . " - ". ($head->get('subject') || 'Subjectless message'));
 
            # NOTE:: see the comments at the end of the sub.
            Encode::_utf8_off( $lines[$_] ) foreach ( 0 .. $#lines );
@@ -289,11 +289,13 @@ sub DecodeMIMEWordsToEncoding {
     my $str = shift;
     my $enc = shift;
 
-   
-    @_ = $str =~ m/([^=]*)=\?([^?]+)\?([QqBb])\?([^?]+)\?=([^=]*)/g;
-
+    @_ = $str =~ m/(.*?)=\?([^?]+)\?([QqBb])\?([^?]+)\?=([^=]*)/gc;
     return ($str) unless (@_);
 
+    # add everything that hasn't matched to the end of the latest
+    # string in array this happen when we have 'key="=?encoded?="; key="plain"'
+    $_[-1] .= substr($str, pos $str);
+
     $str = "";
     while (@_) {
        my ($prefix, $charset, $encoding, $enc_str, $trailing) =