This project is archived and is in readonly mode.

#3657 ✓stale
luis.lopez (at branelabs)

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

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

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"

Comments and changes to this ticket

  • Rohit Arondekar

    Rohit Arondekar October 9th, 2010 @ 03:08 AM

    • 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.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages