Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Correctly format mbox From headers per RFC4155

Fixes #483
  • Loading branch information...
commit 47f1c31083643b35455a31821a63a29a6a3dec95 1 parent 7548347
@jeremy jeremy authored
View
1  CHANGELOG.rdoc
@@ -14,6 +14,7 @@ Performance:
* Close pull request 488 - Speed up field construction & comparison (bpot)
Bugs:
+* Correctly format mbox From headers per RFC4155 (bpot, jeremy)
* Fix bogus '=' at the end of some quoted-printable messages (jeremy)
* Shouldn't be fooled into encoding strings on 1.8 by unrelated Encoding constant (emiellohr, jeremy)
* Header encoding should be US-ASCII, not the default external encoding (jeremy)
View
17 lib/mail/elements/envelope_from_element.rb
@@ -26,8 +26,21 @@ def address
@address
end
- def to_s(*args)
- "#{@info}; #{@date_time.to_s(*args)}"
+ # RFC 4155:
+ # a timestamp indicating the UTC date and time when the message
+ # was originally received, conformant with the syntax of the
+ # traditional UNIX 'ctime' output sans timezone (note that the
+ # use of UTC precludes the need for a timezone indicator);
+ def formatted_date_time
+ if @date_time.respond_to?(:ctime)
+ @date_time.ctime
+ else
+ @date_time.strftime '%a %b %e %T %Y'
+ end
+ end
+
+ def to_s
+ "#{@address} #{formatted_date_time}"
end
end
View
8 spec/mail/elements/envelope_from_element_spec.rb
@@ -28,4 +28,12 @@
end
end
+ describe 'formatting' do
+ it 'should format delivery date using UNIX ctime style' do
+ time = Time.now
+ envelope = Mail::EnvelopeFromElement.new("mikel@test.lindsaar.net #{time.ctime}")
+ envelope.to_s.should eq "mikel@test.lindsaar.net #{time.ctime}"
+ end
+ end
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.