Browse files

Fixing missing trailing CRLF in content type field - Closes issue #57

…- Kudos to Henry Flower for finding it
  • Loading branch information...
1 parent 0cc2fd9 commit 52c60ee41623a1dbd1552557f270a358969a780f @mikel committed Sep 11, 2010
View
1 CHANGELOG.rdoc
@@ -9,6 +9,7 @@
* Added Mail.read_from_string as an explicit method (mcansky)
* Fixed bounce detection for multipart reports that contain a human readable report status part
* Closed Issue #65 found (incredibly) by quetz - major Kudos for bug hunting
+* Fixed missing trailing CRLF in content type field - Closes issue #57 - Kudos to Henry Flower for finding it
== Sat Sep 11 01:32:13 UTC 2010 Mikel Lindsaar <mikel@rubyx.com>
View
4 lib/mail/fields/content_type_field.rb
@@ -109,11 +109,11 @@ def filename
# TODO: Fix this up
def encoded
if parameters.length > 0
- p = ";\r\n\s#{parameters.encoded}\r\n"
+ p = ";\r\n\s#{parameters.encoded}"
else
p = ""
end
- "#{CAPITALIZED_FIELD}: #{content_type}" + p
+ "#{CAPITALIZED_FIELD}: #{content_type}#{p}\r\n"
end
def decoded
View
5 spec/mail/fields/content_type_field_spec.rb
@@ -93,6 +93,11 @@
end
it "should render encoded" do
+ c = Mail::ContentTypeField.new('Content-Type: text/plain')
+ c.encoded.should == "Content-Type: text/plain\r\n"
+ end
+
+ it "should render encoded with parameters" do
c = Mail::ContentTypeField.new('text/plain; charset=US-ASCII; format=flowed')
c.encoded.should == %Q{Content-Type: text/plain;\r\n\scharset=US-ASCII;\r\n\sformat=flowed\r\n}
end
View
22 spec/mail/message_spec.rb
@@ -2,21 +2,33 @@
require 'spec_helper'
describe Mail::Message do
-
+
def basic_email
"To: mikel\r\nFrom: bob\r\nSubject: Hello!\r\n\r\nemail message\r\n"
end
-
+
describe "initialization" do
-
+
it "should instantiate empty" do
Mail::Message.new.class.should == Mail::Message
end
-
+
+ it "should return a basic email" do
+ mail = Mail.new
+ mail = Mail.new(mail.to_s)
+ mail.date.should_not be_blank
+ mail.message_id.should_not be_blank
+ mail.mime_version.should == "1.0"
+ mail.content_type.should == "text/plain"
+ mail.content_transfer_encoding.should == "7bit"
+ mail.subject.should be_blank
+ mail.body.should be_blank
+ end
+
it "should instantiate with a string" do
Mail::Message.new(basic_email).class.should == Mail::Message
end
-
+
it "should allow us to pass it a block" do
mail = Mail::Message.new do
from 'mikel@me.com'

0 comments on commit 52c60ee

Please sign in to comment.