Bugs: Browse | Submit New | Admin

[#22170] ReceivedHeader fails when receiving email with mismatched parenthesis

Date:
2008-09-26 01:37
Priority:
3
Submitted By:
Lon Baker (lonbaker)
Assigned To:
Nobody (None)
Category:
None
State:
Open
Summary:
ReceivedHeader fails when receiving email with mismatched parenthesis

Detailed description
While technical invalid, a large number of valid senders send email with mismatched parenthesis in the ReceivedHeader.

Throwing an error and aborting parsing is not a good solution.

A better solution is to escape all parenthesis in the received header when they are mismatched.

This allows the the regular parser to continue and pass all tests.

module TextUtils
def quote_parentheses
    if @body.count("(") != @body.count(")")
        @body.gsub!(/\(/, "\\(")
        @body.gsub!(/\)/, "\\)")
    end
end
end

class ReceivedHeader < StructuredHeader
    private
    def init
      quote_parentheses
      @from = @by = @via = @with = @id = @_for = nil
      @with = []
      @date = nil
    end
  end

Add A Comment: Notepad

Please login


Followup

Message
Date: 2008-11-17 15:18
Sender: Mikel Lindsaar

Lon, thanks for this.

I created a test email with the example you provided, but parsing
it does not throw an error.  It just deletes the offending header
silently.

Could you attach an example (sanitized) email?

Thanks!

Mikel
Date: 2008-09-26 01:41
Sender: Lon Baker

Example: 

Received: from jsj1wlrmd001.webex.com (by jsj1wlrmd001.webex.com
(8.12.10/8.12.11) with ESMTP id m8MKKPTs022429
	for <xxxx@example.com>; Mon, 22 Sep 2008 20:20:25 GMT

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

No Changes Have Been Made to This Item