{"action":"created","issue":{"url":"https://api.github.com/repos/mikel/mail/issues/278","labels_url":"https://api.github.com/repos/mikel/mail/issues/278/labels{/name}","comments_url":"https://api.github.com/repos/mikel/mail/issues/278/comments","events_url":"https://api.github.com/repos/mikel/mail/issues/278/events","html_url":"https://github.com/mikel/mail/pull/278","id":1501317,"number":278,"title":"Adds Mail::Message#without_attachments! that removes all message's attachments (issue #33)","user":{"login":"vitorbaptista","id":76945,"avatar_url":"https://avatars.githubusercontent.com/u/76945?v=3","gravatar_id":"","url":"https://api.github.com/users/vitorbaptista","html_url":"https://github.com/vitorbaptista","followers_url":"https://api.github.com/users/vitorbaptista/followers","following_url":"https://api.github.com/users/vitorbaptista/following{/other_user}","gists_url":"https://api.github.com/users/vitorbaptista/gists{/gist_id}","starred_url":"https://api.github.com/users/vitorbaptista/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vitorbaptista/subscriptions","organizations_url":"https://api.github.com/users/vitorbaptista/orgs","repos_url":"https://api.github.com/users/vitorbaptista/repos","events_url":"https://api.github.com/users/vitorbaptista/events{/privacy}","received_events_url":"https://api.github.com/users/vitorbaptista/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2011-08-27T18:06:52Z","updated_at":"2015-03-02T18:42:24Z","closed_at":"2012-01-14T00:44:11Z","pull_request":{"url":"https://api.github.com/repos/mikel/mail/pulls/278","html_url":"https://github.com/mikel/mail/pull/278","diff_url":"https://github.com/mikel/mail/pull/278.diff","patch_url":"https://github.com/mikel/mail/pull/278.patch"},"body":"Hi,\r\n\r\nI've implemented a method #without_attachments! that requires less memory than the solution proposed by ledermann in issue #33. I'm working on creating a #without_attachments that's not destructive, simply returning a new instance with the attachments removed, but haven't had success so far.\r\n\r\nThe only problem with this implementation, AFAIK, is that it doesn't works for RFC822 emails. I couldn't find out how to remove only te attachment from its body. Any ideas?\r\n\r\nThanks,\r\nVítor Baptista."},"comment":{"url":"https://api.github.com/repos/mikel/mail/issues/comments/76775698","html_url":"https://github.com/mikel/mail/pull/278#issuecomment-76775698","issue_url":"https://api.github.com/repos/mikel/mail/issues/278","id":76775698,"user":{"login":"TylerRick","id":14151,"avatar_url":"https://avatars.githubusercontent.com/u/14151?v=3","gravatar_id":"","url":"https://api.github.com/users/TylerRick","html_url":"https://github.com/TylerRick","followers_url":"https://api.github.com/users/TylerRick/followers","following_url":"https://api.github.com/users/TylerRick/following{/other_user}","gists_url":"https://api.github.com/users/TylerRick/gists{/gist_id}","starred_url":"https://api.github.com/users/TylerRick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TylerRick/subscriptions","organizations_url":"https://api.github.com/users/TylerRick/orgs","repos_url":"https://api.github.com/users/TylerRick/repos","events_url":"https://api.github.com/users/TylerRick/events{/privacy}","received_events_url":"https://api.github.com/users/TylerRick/received_events","type":"User","site_admin":false},"created_at":"2015-03-02T18:42:24Z","updated_at":"2015-03-02T18:42:24Z","body":"@wtfiwtz said that \"Calling without_attachments! removes Part 1.2 and Part 1.3\". That is how I would *expect* it to work (remove *all* attachments). But when I tried it, it didn't move any attachments that were within \"nested\" parts.\r\n\r\nI checked the tests for `without_attachments!` and they didn't even include a test case for a typical multipart message with attachments! So I added a test case that uses the `mime_emails/raw_email7` fixture and found that the attachment \"parts\" were in fact still there after calling `without_attachments!`...\r\n\r\nBefore:\r\n```\r\n1. #<Mail::Part:33581720, Multipart: true, Headers: <Content-Type: multipart/mixed; boundary=Apple-Mail-12-196940926>>\r\n1.1. #<Mail::Part:33349020, Multipart: false, Headers: <Content-Type: text/plain; charset=ISO-8859-1; delsp=yes; format=flowed>, <Content-Transfer-Encoding: quoted-printable>>\r\n1.2. #<Mail::Part:33344680, Multipart: false, Headers: <Content-Type: text/x-ruby-script; x-unix-mode=0666; name=\"test.rb\">, <Content-Transfer-Encoding: 7bit>, <Content-Disposition: attachment; filename=test.rb>>\r\n1.3. #<Mail::Part:33258280, Multipart: false, Headers: <Content-Type: application/pdf; x-unix-mode=0666; name=\"test.pdf\">, <Content-Transfer-Encoding: base64>, <Content-Disposition: inline; filename=test.pdf>>\r\n1.4. #<Mail::Part:33253840, Multipart: false, Headers: <Content-Type: text/plain; charset=US-ASCII; format=flowed>, <Content-Transfer-Encoding: 7bit>>\r\n2. #<Mail::Part:33495940, Multipart: false, Headers: <Content-Type: application/pkcs7-signature; name=smime.p7s>, <Content-Transfer-Encoding: base64>, <Content-Disposition: attachment; filename=smime.p7s>>\r\n```\r\n\r\nAfter:\r\n```\r\n1. #<Mail::Part:30131520, Multipart: true, Headers: <Content-Type: multipart/mixed; boundary=Apple-Mail-12-196940926; charset=UTF-8>, <Content-Transfer-Encoding: 7bit>>\r\n1.1. #<Mail::Part:30107240, Multipart: false, Headers: <Content-Type: text/plain; charset=ISO-8859-1; delsp=yes; format=flowed>, <Content-Transfer-Encoding: quoted-printable>>\r\n1.2. #<Mail::Part:30078140, Multipart: false, Headers: <Content-Type: text/plain; charset=US-ASCII; format=flowed>, <Content-Transfer-Encoding: 7bit>>\r\n1.3. #<Mail::Part:30063180, Multipart: false, Headers: <Content-Type: text/x-ruby-script; charset=UTF-8; name=test.rb; x-unix-mode=0666>, <Content-Transfer-Encoding: 7bit>, <Content-Disposition: attachment; filename=test.rb>>\r\n1.4. #<Mail::Part:30058620, Multipart: false, Headers: <Content-Type: application/pdf; charset=UTF-8; name=test.pdf; x-unix-mode=0666>, <Content-Transfer-Encoding: base64>, <Content-Disposition: inline; filename=test.pdf>, <Content-ID: <54f4adcc351fa_47e592799448770@k3tyler.mail>>>\r\n```\r\n\r\nI think it needs to look for attachments *recursively*, the same way that `#attachments` (or more precisely, `AttachmentsList#initialize`) does. When I made that change, the parts list looks like this now after calling `without_attachments!`:\r\n\r\n```\r\n1. #<Mail::Part:36423960, Multipart: true, Headers: <Content-Type: multipart/mixed; boundary=Apple-Mail-12-196940926; charset=UTF-8>, <Content-Transfer-Encoding: 7bit>>\r\n1.1. #<Mail::Part:36391680, Multipart: false, Headers: <Content-Type: text/plain; charset=ISO-8859-1; delsp=yes; format=flowed>, <Content-Transfer-Encoding: quoted-printable>>\r\n1.2. #<Mail::Part:36379080, Multipart: false, Headers: <Content-Type: text/plain; charset=US-ASCII; format=flowed>, <Content-Transfer-Encoding: 7bit>>\r\n```\r\n\r\nI will submit a pull request with these fixes in a minute..."}}