mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Don't error while processing encoded attachment names #1340 [lon@speedymac.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1390 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
cf1e2a84ff
commit
481d579734
4 changed files with 62 additions and 2 deletions
|
@ -1,5 +1,7 @@
|
|||
*SVN*
|
||||
|
||||
* Don't cause an error when parsing an encoded attachment name #1340 [lon@speedymac.com]
|
||||
|
||||
* Nested multipart message parts are correctly processed in TMail::Mail#body
|
||||
|
||||
* BCC headers are removed when sending via SMTP #1402
|
||||
|
|
|
@ -206,8 +206,12 @@ module TMail
|
|||
|
||||
def decode_RFC2231( str )
|
||||
m = RFC2231_ENCODED.match(str) or return str
|
||||
NKF.nkf(NKF_FLAGS[$KCODE],
|
||||
m.post_match.gsub(/%[\da-f]{2}/in) {|s| s[1,2].hex.chr })
|
||||
begin
|
||||
NKF.nkf(NKF_FLAGS[$KCODE],
|
||||
m.post_match.gsub(/%[\da-f]{2}/in) {|s| s[1,2].hex.chr })
|
||||
rescue
|
||||
m.post_match.gsub(/%[\da-f]{2}/in, "")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
47
actionmailer/test/fixtures/raw_email8
vendored
Normal file
47
actionmailer/test/fixtures/raw_email8
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
From xxxxxxxxx.xxxxxxx@gmail.com Sun May 8 19:07:09 2005
|
||||
Return-Path: <xxxxxxxxx.xxxxxxx@gmail.com>
|
||||
Message-ID: <e85734b90505081209eaaa17b@mail.gmail.com>
|
||||
Date: Sun, 8 May 2005 14:09:11 -0500
|
||||
From: xxxxxxxxx xxxxxxx <xxxxxxxxx.xxxxxxx@gmail.com>
|
||||
Reply-To: xxxxxxxxx xxxxxxx <xxxxxxxxx.xxxxxxx@gmail.com>
|
||||
To: xxxxx xxxx <xxxxx@xxxxxxxxx.com>
|
||||
Subject: Fwd: Signed email causes file attachments
|
||||
In-Reply-To: <F6E2D0B4-CC35-4A91-BA4C-C7C712B10C13@mac.com>
|
||||
Mime-Version: 1.0
|
||||
Content-Type: multipart/mixed;
|
||||
boundary="----=_Part_5028_7368284.1115579351471"
|
||||
References: <F6E2D0B4-CC35-4A91-BA4C-C7C712B10C13@mac.com>
|
||||
|
||||
------=_Part_5028_7368284.1115579351471
|
||||
Content-Type: text/plain; charset=ISO-8859-1
|
||||
Content-Transfer-Encoding: quoted-printable
|
||||
Content-Disposition: inline
|
||||
|
||||
We should not include these files or vcards as attachments.
|
||||
|
||||
---------- Forwarded message ----------
|
||||
From: xxxxx xxxxxx <xxxxxxxx@xxx.com>
|
||||
Date: May 8, 2005 1:17 PM
|
||||
Subject: Signed email causes file attachments
|
||||
To: xxxxxxx@xxxxxxxxxx.com
|
||||
|
||||
|
||||
Hi,
|
||||
|
||||
Test attachments oddly encoded with japanese charset.
|
||||
|
||||
|
||||
------=_Part_5028_7368284.1115579351471
|
||||
Content-Type: application/octet-stream; name*=iso-2022-jp'ja'01%20Quien%20Te%20Dij%8aat.%20Pitbull.mp3
|
||||
Content-Transfer-Encoding: base64
|
||||
Content-Disposition: attachment
|
||||
|
||||
MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGFDCCAs0w
|
||||
ggI2oAMCAQICAw5c+TANBgkqhkiG9w0BAQQFADBiMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhh
|
||||
d3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVt
|
||||
YWlsIElzc3VpbmcgQ0EwHhcNMDUwMzI5MDkzOTEwWhcNMDYwMzI5MDkzOTEwWjBCMR8wHQYDVQQD
|
||||
ExZUaGF3dGUgRnJlZW1haWwgTWVtYmVyMR8wHQYJKoZIhvcNAQkBFhBzbWhhdW5jaEBtYWMuY29t
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAn90dPsYS3LjfMY211OSYrDQLzwNYPlAL
|
||||
7+/0XA+kdy8/rRnyEHFGwhNCDmg0B6pxC7z3xxJD/8GfCd+IYUUNUQV5m9MkxfP9pTVXZVIYLaBw
|
||||
------=_Part_5028_7368284.1115579351471--
|
||||
|
|
@ -503,5 +503,12 @@ EOF
|
|||
mail = TMail::Mail.parse(fixture)
|
||||
assert_equal "This is the first part.\n\nAttachment: test.pdf\n\n\nAttachment: smime.p7s\n", mail.body
|
||||
end
|
||||
|
||||
def test_decode_encoded_attachment_filename
|
||||
fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email8")
|
||||
mail = TMail::Mail.parse(fixture)
|
||||
attachment = mail.attachments.last
|
||||
assert_equal "01QuienTeDijat.Pitbull.mp3", attachment.original_filename
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue