bounce_email 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ce130775edb415b7fbe1bb73dd5ede660400cb3
4
- data.tar.gz: 47ec5c5d48f725c357f7a25056e5b71c3533307b
3
+ metadata.gz: 389a9e0770cb526a74372b21a69bec34e74e2838
4
+ data.tar.gz: 48acb9da2dc68c2a86e3ade32ce0ddb5fcefc9f8
5
5
  SHA512:
6
- metadata.gz: 959c42432cc8e1e0d321da76835bf58cec27b7bcb2a60814ffaa298ed4e2a736f19d4d1ef0d90a31ed1025e389cf93d42cf8ae835ae25640a9d9d73a49f15cc2
7
- data.tar.gz: b865011fe075ab2f8aaf3d265a766c58746844c7c858f8e97e5094f018e80d9f64760b149237da001f28699294cd63071ca6ccb5918202dffb627197e61b879c
6
+ metadata.gz: 88e393b37a5868b299bc1551d68feb785f677f47fbe2b340e218a1c091a815fd94d07c701586fda52e084cb4153bad586e016b3f7dd46f189481f6d7e31a4866
7
+ data.tar.gz: 3f5c4fa7c27729d0de1e0f29ba1fcc02cfc00e11923babe6f7817e7bc4dad1ca260e1cbcc5674fd3eaec076e0a5eeaa75674866b5a300f9bdad5810f2a27a5af
data/HISTORY.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.2.8
2
+
3
+ * Properly parse the email original when it's attached in the last part of a multipart bounce email (@blainejohnson17, livebg/bounce_email#12). Read more about [the issue and the reasoning behind the fix here](https://github.com/livebg/bounce_email/pull/12#issuecomment-312431646).
4
+
1
5
  ## 0.2.7
2
6
 
3
7
  * Extract and save the bounced email's date field in the email original (@blainejohnson17, livebg/bounce_email#11)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.7
1
+ 0.2.8
@@ -221,7 +221,7 @@ module BounceEmail
221
221
  def get_original_mail(mail) #worked alright for me, for sure this has to be extended
222
222
  original =
223
223
  if mail.multipart?
224
- ::Mail.new(mail.parts.last)
224
+ ::Mail.new(mail.parts.last.body)
225
225
  elsif i = index_of_original_message_delimiter(mail)
226
226
  ::Mail.new(extract_original_message_after_delimiter(mail, i))
227
227
  end
@@ -242,19 +242,7 @@ module BounceEmail
242
242
  end
243
243
 
244
244
  def extract_and_assign_fields_from(bounce, original)
245
- if original.message_id.nil?
246
- original.add_message_id extract_field_from(original, /^Message-ID:/)
247
- end
248
-
249
- original.from ||= extract_field_from(original, /^From:/)
250
-
251
- original.to ||= (extract_original_to_field_from_header(bounce) ||
252
- extract_field_from(original, /^To:/))
253
-
254
- original.subject ||= extract_field_from(original, /^Subject:/)
255
-
256
- original.date ||= extract_field_from(original, /^Date:/)
257
-
245
+ original.to ||= extract_original_to_field_from_header(bounce)
258
246
  original
259
247
  end
260
248
 
@@ -262,15 +250,5 @@ module BounceEmail
262
250
  header = mail.header["X-Failed-Recipients"]
263
251
  header.value if header && header.value
264
252
  end
265
-
266
- def extract_field_from(mail, field_name)
267
- lines = original_mail_body_lines(mail)
268
- field = lines.detect { |line| line.match field_name }
269
- field.split(':', 2).last.strip if field
270
- end
271
-
272
- def original_mail_body_lines(mail)
273
- @original_mail_body_lines ||= mail.body.to_s.split(/(?:\r\n|\n)+/)
274
- end
275
253
  end
276
254
  end
@@ -108,7 +108,7 @@ class BounceEmailTest < Test::Unit::TestCase
108
108
  end
109
109
 
110
110
  def test_original_message_with_multipart_mails
111
- multipart_mails = %w(05 07 10 11 13 15 16 23 24)
111
+ multipart_mails = %w(04 05 07 10 11 13 15 16 23 24)
112
112
  multipart_mails.map do |file|
113
113
  mail = File.join(File.dirname(__FILE__), 'bounces', "tt_bounce_#{file}.txt")
114
114
  bounce = BounceEmail::Mail.new Mail.read(mail)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bounce_email
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Bielohlawek
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2017-05-15 00:00:00.000000000 Z
14
+ date: 2017-07-01 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: mail