Bug in 3.2.3 I18N.pm

Hi,

i found a bug in I18N.pm. From 3.2.2 to 3.2.3 the method “DecodeMIMEWordsToEncoding” changed. The ToDo-comment says:

It’s legal for headers to contain mime-encoded commas and semicolons which

#should not be treated as address separators. (Encoding == quoting here)

until this is fixed, we must escape any string containing a comma or semicolon

this is only a bandaid

While this is correct someone missed a very important point here. Several MUAs/MTAs tend to encode the quotes and rely on that as well. This is the case for Exchange 5.5 etc. So if you decode the MIME word it already contains the necessary quotes but the change in 3.2.3 quoted this again, resulting in

““Koopmann, Jan-Peter””

like strings. This later on crashes in EmailParser.pm etc. We figured this out since mails from people with special characters in their name (hence the encoding), commas in their real name and MTAs that encode the quotes were not accepted by RT 3.2.3 anymore. I have not had a look at 3.4 yet to see if this is fixed but it should be fixed in the 3.2 branch as well.

This patch works for us:

I18N.pm Mon Nov 15 17:08:53 2004
+++ /usr/local/rt3/lib/RT/I18N.pm Mon Apr 4 11:46:01 2005
@@ -331,7 +331,17 @@
# until this is fixed, we must escape any string containing a comma or semicolon
# this is only a bandaid

  •    $enc_str = qq{"$enc_str"} if ($enc_str =~ /[,;]/);                                     
    
  •   # JPK 04.04.2005
    
  •   # Some MUAs/MTAs use quotes within the encoded string (e.g. Exchange 5.5, 
    
  •   # Exchange 2003 with patches etc.). Even though this is not RFC conform it
    
  •   # happens a lot and several MUAs expect this (e.g. older Outlooks, web
    
  •   # interfaces). Unfortunately in these cases RT decoded the MIME word
    
  •   # (including the encoded quotes) and quoted the string again resulting in
    
  •   # ""whatever"" which again crashes things later on. Therefore
    
  •   # this patch makes sure that the encoded string is not itself quoted already.
    
  •    $enc_str = qq{"$enc_str"} if ($enc_str !~ /^".*"$/) && ($enc_str =~ /[,;]/); 
      $str .= $prefix . $enc_str . $trailing;
    
    }

Kind regards,

Jan-Peter Koopmann
Dipl.-Wirtschaftsinformatiker
Geschäftsführer / COO

Seceidos GmbH
Robert-Bosch-Str.7
64293 Darmstadt/Germany

Phone: +49 (6151) 66843-43
Fax: +49 (6151) 66843-52
E-Mail: jan-peter.koopmann@seceidos.de
Web: http://www.seceidos.de