Closed Bug 418930 Opened 14 years ago Closed 14 years ago

email_in.pl doesn't handle quotes around charset item in content-type header - "Unknown encoding" error

Categories

(Bugzilla :: Incoming Email, defect)

defect
Not set
major

Tracking

()

RESOLVED DUPLICATE of bug 413672

People

(Reporter: bob.crystaltech, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-us) AppleWebKit/523.10.3 (KHTML, like Gecko) Version/3.0.4 Safari/523.10
Build Identifier: Version 3.0.3

When the charset portion of the Content-type: header of incoming messages is put in quotes, email_in.pl chokes on it and dies. The following is what's logged:

procmail: Couldn't determine implicit lockfile from "/usr/local/ 
apache2/htdocs/bugzilla/email_in.pl" 
Parsing Email 
Splitting Body and Attachments [Type: text/plain; charset="US- 
ASCII"]... 
Part Content-Type: text/plain; charset="US-ASCII" 
Part Character Encoding: "US-ASCII" 
Unknown encoding '"US-ASCII"' From x...@yyy.com  Thu Feb 21 16:22:41 
2008 
 Subject: [Bug 4] YA test 
  Folder: /usr/local/apache2/htdocs/bugzilla/email_in.pl -vv               2809 

In this test case, the following headers are the relevant portion of what the message came in with:

Mime-version: 1.0 
Content-type: text/plain; 
        charset="US-ASCII" 
Content-transfer-encoding: 7bit 


Using Microsoft Entourage 2004 (v11.3.6) to send a comment to a bug, the following headers are included with the message:

Mime-version: 1.0 
Content-type: text/plain; 
        charset="US-ASCII" 
Content-transfer-encoding: 7bit 



Reproducible: Always

Steps to Reproduce:
The above test message was sent with Microsoft Entourage 2004 (v11.3.6). I tried sending a message with the command line "mail" command, and it posts fine.



I'm not sure if it's the same root problem, but in trying to diagnose this, I ran across one other instance of it on Google:

<http://groups.google.com/group/mozilla.support.bugzilla/browse_thread/thread/592da2f886918a54/2bcf8b9374c1bfbb%232bcf8b9374c1bfbb>
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 413672
The problem is that the get_text_alternative routine gets confused by the quotes, and errantly tries to include them in the charset string itself. I've corrected the problem by changing the following line in that subroutine:

        if ($ct =~ /charset=([^;]+)/) {

I changed it to:

        if ($ct =~ /charset="*([^";]+)/) {

My revised regex accepts an optional set of quotes around the charset string.
You need to log in before you can comment on or make changes to this bug.