Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Actionmailer, ReceivedHeader: parsing fails when received header has only numbers

#3657

When a mail have a received header whose id has only numbers (0-9), this header parsing fails. For example:

puts RAILS_GEM_VERSION

puts "---- good header "
good_header = "Received: from localhost.localdomain (localhost [127.0.0.1])\n\tby myself (Postfix) with ESMTP id 251A\n\tfor <aaa@aaa.aaa>; Mon,  4 Jan 2010 13:19:08 +0100 (CET)\nFrom: <bbb@bbb.bbb>\nSubject: header ok\nTo: aaa@aaa.com\n\nheader works if there are letters in id\n"

mail_good= TMail::Mail.parse good_header
p mail_good.header["received"][0]
p mail_good.header["received"][0].id
p mail_good.header["received"][0].by

puts "---- bad header "
bad_header = "Received: from localhost.localdomain (localhost [127.0.0.1])\n\tby myself (Postfix) with ESMTP id 2511\n\tfor <aaa@aaa.aaa>; Mon,  4 Jan 2010 13:19:08 +0100 (CET)\nFrom: <bbb@bbb.bbb>\nSubject: header fail\nTo: aaa@aaa.com\n\nheader doesn't work if there aren't letters in id\n"

mail_bad= TMail::Mail.parse bad_header
p mail_bad.header["received"][0]
p mail_bad.header["received"][0].id
p mail_bad.header["received"][0].by

Received headers only differs in id (2511 vs 251A) but second one isn't parsed correctly. This is the result:

$ script/runner /tmp/mails_testing.rb 
2.3.5
---- good header 
#<TMail::ReceivedHeader "from localhost.localdomain (localhost [127.0.0.1])\n by myself (Postfix) with ESMTP id 251A for <aaa@aaa.aaa>; Mon,  4 Jan 2010 13:19:08 +0100 (CET)">
"251A"
"myself"
---- bad header 
#<TMail::ReceivedHeader "from localhost.localdomain (localhost [127.0.0.1])\n by myself (Postfix) with ESMTP id 2511 for <aaa@aaa.aaa>; Mon,  4 Jan 2010 13:19:08 +0100 (CET)">
nil
nil

As you can see, the second mail just return nil for "id" or "by"

Reported by luis.lopez (at branelabs) · January 5th, 2010 @ 11:56 AM

State: stale
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Rohit Arondekar
    Rohit Arondekar
    • State changed from new to stale
    • Importance changed from to Low

    Marking ticket as stale. If this is still an issue please leave a comment with suggested changes, creating a patch with tests, rebasing an existing patch or just confirming the issue on a latest release or master/branches.

    October 9th, 2010 @ 03:08 AM