forked from mikel/mail
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the bogus '=' at the end of some quoted-printable messages.
Trailing CRLF is significant in Quoted-Printable transfer encoding. Stripping trailing whitespace corrupts the encoding, resulting in odd '=' chars showing up at the end of decoded emails. Fixed by only stripping leading whitespace. Closes mikel#440
- Loading branch information
Showing
5 changed files
with
14 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -254,7 +254,7 @@ | |
mail.from.should eq ["[email protected]"] | ||
mail.subject.should eq "Re: TEST テストテスト" | ||
mail.message_id.should eq '[email protected]' | ||
mail.body.should eq "Hello" | ||
mail.body.decoded.should eq "Hello\n" | ||
end | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -237,7 +237,7 @@ def basic_email | |
|
||
it "should set a raw source instance variable to equal the passed in message" do | ||
mail = Mail::Message.new(basic_email) | ||
mail.raw_source.should eq basic_email.strip | ||
mail.raw_source.should eq basic_email | ||
end | ||
|
||
it "should set the raw source instance variable to '' if no message is passed in" do | ||
|
@@ -259,7 +259,7 @@ def basic_email | |
|
||
it "should give the body class the body to parse" do | ||
body = Mail::Body.new("email message") | ||
Mail::Body.should_receive(:new).with("email message").and_return(body) | ||
Mail::Body.should_receive(:new).with("email message\r\n").and_return(body) | ||
mail = Mail::Message.new(basic_email) | ||
mail.body #body calculates now lazy so need to ask for it | ||
end | ||
|
@@ -290,8 +290,8 @@ def basic_email | |
|
||
it "should allow for whitespace at the start of the email" do | ||
mail = Mail.new("\r\n\r\nFrom: mikel\r\n\r\nThis is the body") | ||
mail.from.should eq ['mikel'] | ||
mail.body.to_s.should eq 'This is the body' | ||
mail.from.should eq ['mikel'] | ||
end | ||
|
||
it "should read in an email message with the word 'From' in it multiple times and parse it" do | ||
|
@@ -303,7 +303,7 @@ def basic_email | |
it "should parse non-UTF8 sources" do | ||
mail = Mail::Message.new(File.read(fixture('emails', 'multi_charset', 'japanese_shiftjis.eml'))) | ||
mail.to.should eq ["[email protected]"] | ||
mail.decoded.should eq "すみません。" | ||
mail.decoded.should eq "すみません。\n\n" | ||
end | ||
end | ||
|
||
|
@@ -1254,6 +1254,10 @@ def basic_email | |
mail.body.encoded.should eq "VGhlIGJvZHk=\r\n" | ||
end | ||
|
||
it 'should not strip the raw mail source in case the trailing \r\n is meaningful' do | ||
Mail.new("Content-Transfer-Encoding: quoted-printable;\r\n\r\nfoo=\r\nbar=\r\nbaz=\r\n").decoded.should eq 'foobarbaz' | ||
end | ||
|
||
end | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters