rack-mail_exception 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (321) hide show
  1. data/.document +5 -0
  2. data/.gitignore +22 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +38 -0
  5. data/Rakefile +56 -0
  6. data/VERSION +1 -0
  7. data/lib/rack/mail_exception.rb +103 -0
  8. data/test/helper.rb +13 -0
  9. data/test/test_rack_mail_exception.rb +93 -0
  10. data/vendor/mail/.bundle/config +2 -0
  11. data/vendor/mail/CHANGELOG.rdoc +370 -0
  12. data/vendor/mail/Dependencies.txt +3 -0
  13. data/vendor/mail/Gemfile +17 -0
  14. data/vendor/mail/README.rdoc +572 -0
  15. data/vendor/mail/ROADMAP +92 -0
  16. data/vendor/mail/Rakefile +41 -0
  17. data/vendor/mail/TODO.rdoc +9 -0
  18. data/vendor/mail/lib/mail.rb +76 -0
  19. data/vendor/mail/lib/mail/attachments_list.rb +99 -0
  20. data/vendor/mail/lib/mail/body.rb +287 -0
  21. data/vendor/mail/lib/mail/configuration.rb +67 -0
  22. data/vendor/mail/lib/mail/core_extensions/blank.rb +26 -0
  23. data/vendor/mail/lib/mail/core_extensions/nil.rb +11 -0
  24. data/vendor/mail/lib/mail/core_extensions/string.rb +27 -0
  25. data/vendor/mail/lib/mail/elements.rb +14 -0
  26. data/vendor/mail/lib/mail/elements/address.rb +306 -0
  27. data/vendor/mail/lib/mail/elements/address_list.rb +74 -0
  28. data/vendor/mail/lib/mail/elements/content_disposition_element.rb +30 -0
  29. data/vendor/mail/lib/mail/elements/content_location_element.rb +25 -0
  30. data/vendor/mail/lib/mail/elements/content_transfer_encoding_element.rb +24 -0
  31. data/vendor/mail/lib/mail/elements/content_type_element.rb +35 -0
  32. data/vendor/mail/lib/mail/elements/date_time_element.rb +26 -0
  33. data/vendor/mail/lib/mail/elements/envelope_from_element.rb +34 -0
  34. data/vendor/mail/lib/mail/elements/message_ids_element.rb +29 -0
  35. data/vendor/mail/lib/mail/elements/mime_version_element.rb +26 -0
  36. data/vendor/mail/lib/mail/elements/phrase_list.rb +21 -0
  37. data/vendor/mail/lib/mail/elements/received_element.rb +30 -0
  38. data/vendor/mail/lib/mail/encodings.rb +258 -0
  39. data/vendor/mail/lib/mail/encodings/7bit.rb +31 -0
  40. data/vendor/mail/lib/mail/encodings/8bit.rb +31 -0
  41. data/vendor/mail/lib/mail/encodings/base64.rb +33 -0
  42. data/vendor/mail/lib/mail/encodings/binary.rb +31 -0
  43. data/vendor/mail/lib/mail/encodings/quoted_printable.rb +38 -0
  44. data/vendor/mail/lib/mail/encodings/transfer_encoding.rb +58 -0
  45. data/vendor/mail/lib/mail/envelope.rb +35 -0
  46. data/vendor/mail/lib/mail/field.rb +223 -0
  47. data/vendor/mail/lib/mail/field_list.rb +33 -0
  48. data/vendor/mail/lib/mail/fields.rb +35 -0
  49. data/vendor/mail/lib/mail/fields/bcc_field.rb +56 -0
  50. data/vendor/mail/lib/mail/fields/cc_field.rb +55 -0
  51. data/vendor/mail/lib/mail/fields/comments_field.rb +41 -0
  52. data/vendor/mail/lib/mail/fields/common/address_container.rb +16 -0
  53. data/vendor/mail/lib/mail/fields/common/common_address.rb +125 -0
  54. data/vendor/mail/lib/mail/fields/common/common_date.rb +42 -0
  55. data/vendor/mail/lib/mail/fields/common/common_field.rb +50 -0
  56. data/vendor/mail/lib/mail/fields/common/common_message_id.rb +43 -0
  57. data/vendor/mail/lib/mail/fields/common/parameter_hash.rb +52 -0
  58. data/vendor/mail/lib/mail/fields/content_description_field.rb +19 -0
  59. data/vendor/mail/lib/mail/fields/content_disposition_field.rb +69 -0
  60. data/vendor/mail/lib/mail/fields/content_id_field.rb +63 -0
  61. data/vendor/mail/lib/mail/fields/content_location_field.rb +42 -0
  62. data/vendor/mail/lib/mail/fields/content_transfer_encoding_field.rb +50 -0
  63. data/vendor/mail/lib/mail/fields/content_type_field.rb +185 -0
  64. data/vendor/mail/lib/mail/fields/date_field.rb +55 -0
  65. data/vendor/mail/lib/mail/fields/from_field.rb +55 -0
  66. data/vendor/mail/lib/mail/fields/in_reply_to_field.rb +55 -0
  67. data/vendor/mail/lib/mail/fields/keywords_field.rb +44 -0
  68. data/vendor/mail/lib/mail/fields/message_id_field.rb +83 -0
  69. data/vendor/mail/lib/mail/fields/mime_version_field.rb +53 -0
  70. data/vendor/mail/lib/mail/fields/optional_field.rb +13 -0
  71. data/vendor/mail/lib/mail/fields/received_field.rb +67 -0
  72. data/vendor/mail/lib/mail/fields/references_field.rb +55 -0
  73. data/vendor/mail/lib/mail/fields/reply_to_field.rb +55 -0
  74. data/vendor/mail/lib/mail/fields/resent_bcc_field.rb +55 -0
  75. data/vendor/mail/lib/mail/fields/resent_cc_field.rb +55 -0
  76. data/vendor/mail/lib/mail/fields/resent_date_field.rb +35 -0
  77. data/vendor/mail/lib/mail/fields/resent_from_field.rb +55 -0
  78. data/vendor/mail/lib/mail/fields/resent_message_id_field.rb +34 -0
  79. data/vendor/mail/lib/mail/fields/resent_sender_field.rb +62 -0
  80. data/vendor/mail/lib/mail/fields/resent_to_field.rb +55 -0
  81. data/vendor/mail/lib/mail/fields/return_path_field.rb +64 -0
  82. data/vendor/mail/lib/mail/fields/sender_field.rb +67 -0
  83. data/vendor/mail/lib/mail/fields/structured_field.rb +51 -0
  84. data/vendor/mail/lib/mail/fields/subject_field.rb +16 -0
  85. data/vendor/mail/lib/mail/fields/to_field.rb +55 -0
  86. data/vendor/mail/lib/mail/fields/unstructured_field.rb +166 -0
  87. data/vendor/mail/lib/mail/header.rb +262 -0
  88. data/vendor/mail/lib/mail/mail.rb +234 -0
  89. data/vendor/mail/lib/mail/message.rb +1867 -0
  90. data/vendor/mail/lib/mail/network.rb +9 -0
  91. data/vendor/mail/lib/mail/network/delivery_methods/file_delivery.rb +40 -0
  92. data/vendor/mail/lib/mail/network/delivery_methods/sendmail.rb +62 -0
  93. data/vendor/mail/lib/mail/network/delivery_methods/smtp.rb +110 -0
  94. data/vendor/mail/lib/mail/network/delivery_methods/test_mailer.rb +40 -0
  95. data/vendor/mail/lib/mail/network/retriever_methods/imap.rb +18 -0
  96. data/vendor/mail/lib/mail/network/retriever_methods/pop3.rb +149 -0
  97. data/vendor/mail/lib/mail/parsers/address_lists.rb +64 -0
  98. data/vendor/mail/lib/mail/parsers/address_lists.treetop +19 -0
  99. data/vendor/mail/lib/mail/parsers/content_disposition.rb +387 -0
  100. data/vendor/mail/lib/mail/parsers/content_disposition.treetop +46 -0
  101. data/vendor/mail/lib/mail/parsers/content_location.rb +139 -0
  102. data/vendor/mail/lib/mail/parsers/content_location.treetop +20 -0
  103. data/vendor/mail/lib/mail/parsers/content_transfer_encoding.rb +162 -0
  104. data/vendor/mail/lib/mail/parsers/content_transfer_encoding.treetop +20 -0
  105. data/vendor/mail/lib/mail/parsers/content_type.rb +539 -0
  106. data/vendor/mail/lib/mail/parsers/content_type.treetop +58 -0
  107. data/vendor/mail/lib/mail/parsers/date_time.rb +114 -0
  108. data/vendor/mail/lib/mail/parsers/date_time.treetop +11 -0
  109. data/vendor/mail/lib/mail/parsers/envelope_from.rb +194 -0
  110. data/vendor/mail/lib/mail/parsers/envelope_from.treetop +32 -0
  111. data/vendor/mail/lib/mail/parsers/message_ids.rb +45 -0
  112. data/vendor/mail/lib/mail/parsers/message_ids.treetop +15 -0
  113. data/vendor/mail/lib/mail/parsers/mime_version.rb +144 -0
  114. data/vendor/mail/lib/mail/parsers/mime_version.treetop +19 -0
  115. data/vendor/mail/lib/mail/parsers/phrase_lists.rb +45 -0
  116. data/vendor/mail/lib/mail/parsers/phrase_lists.treetop +15 -0
  117. data/vendor/mail/lib/mail/parsers/received.rb +71 -0
  118. data/vendor/mail/lib/mail/parsers/received.treetop +11 -0
  119. data/vendor/mail/lib/mail/parsers/rfc2045.rb +464 -0
  120. data/vendor/mail/lib/mail/parsers/rfc2045.treetop +36 -0
  121. data/vendor/mail/lib/mail/parsers/rfc2822.rb +5318 -0
  122. data/vendor/mail/lib/mail/parsers/rfc2822.treetop +410 -0
  123. data/vendor/mail/lib/mail/parsers/rfc2822_obsolete.rb +3757 -0
  124. data/vendor/mail/lib/mail/parsers/rfc2822_obsolete.treetop +241 -0
  125. data/vendor/mail/lib/mail/part.rb +102 -0
  126. data/vendor/mail/lib/mail/parts_list.rb +34 -0
  127. data/vendor/mail/lib/mail/patterns.rb +30 -0
  128. data/vendor/mail/lib/mail/utilities.rb +181 -0
  129. data/vendor/mail/lib/mail/version.rb +10 -0
  130. data/vendor/mail/lib/mail/version_specific/ruby_1_8.rb +97 -0
  131. data/vendor/mail/lib/mail/version_specific/ruby_1_9.rb +87 -0
  132. data/vendor/mail/lib/tasks/corpus.rake +125 -0
  133. data/vendor/mail/lib/tasks/treetop.rake +10 -0
  134. data/vendor/mail/mail.gemspec +20 -0
  135. data/vendor/mail/reference/US ASCII Table.txt +130 -0
  136. data/vendor/mail/reference/rfc1035 Domain Implementation and Specification.txt +3083 -0
  137. data/vendor/mail/reference/rfc1049 Content-Type Header Field for Internet Messages.txt +451 -0
  138. data/vendor/mail/reference/rfc1344 Implications of MIME for Internet Mail Gateways.txt +586 -0
  139. data/vendor/mail/reference/rfc1345 Character Mnemonics & Character Sets.txt +5761 -0
  140. data/vendor/mail/reference/rfc1524 A User Agent Configuration Mechanism For Multimedia Mail Format Information.txt +675 -0
  141. data/vendor/mail/reference/rfc1652 SMTP Service Extension for 8bit-MIMEtransport.txt +339 -0
  142. data/vendor/mail/reference/rfc1892 Multipart Report .txt +227 -0
  143. data/vendor/mail/reference/rfc1893 Mail System Status Codes.txt +843 -0
  144. data/vendor/mail/reference/rfc2045 Multipurpose Internet Mail Extensions (1).txt +1739 -0
  145. data/vendor/mail/reference/rfc2046 Multipurpose Internet Mail Extensions (2).txt +2467 -0
  146. data/vendor/mail/reference/rfc2047 Multipurpose Internet Mail Extensions (3).txt +843 -0
  147. data/vendor/mail/reference/rfc2048 Multipurpose Internet Mail Extensions (4).txt +1180 -0
  148. data/vendor/mail/reference/rfc2049 Multipurpose Internet Mail Extensions (5).txt +1347 -0
  149. data/vendor/mail/reference/rfc2111 Content-ID and Message-ID URLs.txt +283 -0
  150. data/vendor/mail/reference/rfc2183 Content-Disposition Header Field.txt +675 -0
  151. data/vendor/mail/reference/rfc2231 MIME Parameter Value and Encoded Word Extensions.txt +563 -0
  152. data/vendor/mail/reference/rfc2387 MIME Multipart-Related Content-type.txt +563 -0
  153. data/vendor/mail/reference/rfc2821 Simple Mail Transfer Protocol.txt +3711 -0
  154. data/vendor/mail/reference/rfc2822 Internet Message Format.txt +2859 -0
  155. data/vendor/mail/reference/rfc3462 Reporting of Mail System Administrative Messages.txt +396 -0
  156. data/vendor/mail/reference/rfc3696 Checking and Transformation of Names.txt +898 -0
  157. data/vendor/mail/reference/rfc4155 The application-mbox Media Type.txt +502 -0
  158. data/vendor/mail/reference/rfc4234 Augmented BNF for Syntax Specifications: ABNF.txt +899 -0
  159. data/vendor/mail/reference/rfc822 Standard for the Format of ARPA Internet Text Messages.txt +2900 -0
  160. data/vendor/mail/spec/environment.rb +15 -0
  161. data/vendor/mail/spec/features/making_a_new_message.feature +14 -0
  162. data/vendor/mail/spec/features/steps/env.rb +6 -0
  163. data/vendor/mail/spec/features/steps/making_a_new_message_steps.rb +11 -0
  164. data/vendor/mail/spec/fixtures/attachments/basic_email.eml +31 -0
  165. data/vendor/mail/spec/fixtures/attachments/test.gif +0 -0
  166. data/vendor/mail/spec/fixtures/attachments/test.jpg +0 -0
  167. data/vendor/mail/spec/fixtures/attachments/test.pdf +0 -0
  168. data/vendor/mail/spec/fixtures/attachments/test.png +0 -0
  169. data/vendor/mail/spec/fixtures/attachments/test.tiff +0 -0
  170. data/vendor/mail/spec/fixtures/attachments/test.zip +0 -0
  171. data/vendor/mail/spec/fixtures/attachments//343/201/246/343/201/231/343/201/250.txt +2 -0
  172. data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_content_disposition.eml +29 -0
  173. data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_content_location.eml +32 -0
  174. data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_message_rfc822.eml +92 -0
  175. data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_only_email.eml +17 -0
  176. data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_pdf.eml +70 -0
  177. data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_with_encoded_name.eml +47 -0
  178. data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_with_quoted_filename.eml +60 -0
  179. data/vendor/mail/spec/fixtures/emails/error_emails/cant_parse_from.eml +33 -0
  180. data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_7-bit.eml +231 -0
  181. data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_empty.eml +33 -0
  182. data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_plain.eml +148 -0
  183. data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_qp_with_space.eml +53 -0
  184. data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_spam.eml +44 -0
  185. data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_text-html.eml +50 -0
  186. data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_with_8bits.eml +770 -0
  187. data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_with_semi_colon.eml +269 -0
  188. data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_x_uuencode.eml +79 -0
  189. data/vendor/mail/spec/fixtures/emails/error_emails/empty_group_lists.eml +162 -0
  190. data/vendor/mail/spec/fixtures/emails/error_emails/header_fields_with_empty_values.eml +33 -0
  191. data/vendor/mail/spec/fixtures/emails/error_emails/missing_body.eml +16 -0
  192. data/vendor/mail/spec/fixtures/emails/error_emails/missing_content_disposition.eml +43 -0
  193. data/vendor/mail/spec/fixtures/emails/error_emails/multiple_content_types.eml +25 -0
  194. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email11.eml +34 -0
  195. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email12.eml +32 -0
  196. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email2.eml +114 -0
  197. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email4.eml +59 -0
  198. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email7.eml +66 -0
  199. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_encoded_stack_level_too_deep.eml +53 -0
  200. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_illegal_boundary.eml +58 -0
  201. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_mimepart_without_content_type.eml +94 -0
  202. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_multipart_mixed_quoted_boundary.eml +50 -0
  203. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_nested_attachment.eml +100 -0
  204. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_quoted_illegal_boundary.eml +58 -0
  205. data/vendor/mail/spec/fixtures/emails/mime_emails/sig_only_email.eml +29 -0
  206. data/vendor/mail/spec/fixtures/emails/mime_emails/two_from_in_message.eml +42 -0
  207. data/vendor/mail/spec/fixtures/emails/multi_charset/japanese.eml +9 -0
  208. data/vendor/mail/spec/fixtures/emails/multi_charset/japanese_attachment.eml +27 -0
  209. data/vendor/mail/spec/fixtures/emails/multi_charset/japanese_attachment_long_name.eml +44 -0
  210. data/vendor/mail/spec/fixtures/emails/multipart_report_emails/multi_address_bounce1.eml +179 -0
  211. data/vendor/mail/spec/fixtures/emails/multipart_report_emails/multi_address_bounce2.eml +179 -0
  212. data/vendor/mail/spec/fixtures/emails/multipart_report_emails/report_422.eml +98 -0
  213. data/vendor/mail/spec/fixtures/emails/multipart_report_emails/report_530.eml +97 -0
  214. data/vendor/mail/spec/fixtures/emails/plain_emails/basic_email.eml +31 -0
  215. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email.eml +14 -0
  216. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email10.eml +20 -0
  217. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email5.eml +19 -0
  218. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email6.eml +20 -0
  219. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email8.eml +47 -0
  220. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_bad_time.eml +62 -0
  221. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_double_at_in_header.eml +14 -0
  222. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_incorrect_header.eml +28 -0
  223. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_multiple_from.eml +30 -0
  224. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_quoted_with_0d0a.eml +14 -0
  225. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_reply.eml +32 -0
  226. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_simple.eml +11 -0
  227. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_string_in_date_field.eml +17 -0
  228. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_trailing_dot.eml +21 -0
  229. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_with_bad_date.eml +48 -0
  230. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_with_partially_quoted_subject.eml +14 -0
  231. data/vendor/mail/spec/fixtures/emails/rfc2822/example01.eml +8 -0
  232. data/vendor/mail/spec/fixtures/emails/rfc2822/example02.eml +9 -0
  233. data/vendor/mail/spec/fixtures/emails/rfc2822/example03.eml +7 -0
  234. data/vendor/mail/spec/fixtures/emails/rfc2822/example04.eml +7 -0
  235. data/vendor/mail/spec/fixtures/emails/rfc2822/example05.eml +8 -0
  236. data/vendor/mail/spec/fixtures/emails/rfc2822/example06.eml +10 -0
  237. data/vendor/mail/spec/fixtures/emails/rfc2822/example07.eml +9 -0
  238. data/vendor/mail/spec/fixtures/emails/rfc2822/example08.eml +12 -0
  239. data/vendor/mail/spec/fixtures/emails/rfc2822/example09.eml +15 -0
  240. data/vendor/mail/spec/fixtures/emails/rfc2822/example10.eml +15 -0
  241. data/vendor/mail/spec/fixtures/emails/rfc2822/example11.eml +6 -0
  242. data/vendor/mail/spec/fixtures/emails/rfc2822/example12.eml +8 -0
  243. data/vendor/mail/spec/fixtures/emails/rfc2822/example13.eml +10 -0
  244. data/vendor/mail/spec/fixtures/emails/sample_output_multipart +0 -0
  245. data/vendor/mail/spec/mail/attachments_list_spec.rb +214 -0
  246. data/vendor/mail/spec/mail/body_spec.rb +385 -0
  247. data/vendor/mail/spec/mail/configuration_spec.rb +19 -0
  248. data/vendor/mail/spec/mail/core_extensions/string_spec.rb +62 -0
  249. data/vendor/mail/spec/mail/core_extensions_spec.rb +99 -0
  250. data/vendor/mail/spec/mail/elements/address_list_spec.rb +109 -0
  251. data/vendor/mail/spec/mail/elements/address_spec.rb +609 -0
  252. data/vendor/mail/spec/mail/elements/date_time_element_spec.rb +20 -0
  253. data/vendor/mail/spec/mail/elements/envelope_from_element_spec.rb +31 -0
  254. data/vendor/mail/spec/mail/elements/message_ids_element_spec.rb +43 -0
  255. data/vendor/mail/spec/mail/elements/phrase_list_spec.rb +22 -0
  256. data/vendor/mail/spec/mail/elements/received_element_spec.rb +34 -0
  257. data/vendor/mail/spec/mail/encoding_spec.rb +189 -0
  258. data/vendor/mail/spec/mail/encodings/base64_spec.rb +25 -0
  259. data/vendor/mail/spec/mail/encodings/quoted_printable_spec.rb +25 -0
  260. data/vendor/mail/spec/mail/encodings_spec.rb +664 -0
  261. data/vendor/mail/spec/mail/example_emails_spec.rb +303 -0
  262. data/vendor/mail/spec/mail/field_list_spec.rb +33 -0
  263. data/vendor/mail/spec/mail/field_spec.rb +198 -0
  264. data/vendor/mail/spec/mail/fields/bcc_field_spec.rb +89 -0
  265. data/vendor/mail/spec/mail/fields/cc_field_spec.rb +79 -0
  266. data/vendor/mail/spec/mail/fields/comments_field_spec.rb +25 -0
  267. data/vendor/mail/spec/mail/fields/common/address_container_spec.rb +18 -0
  268. data/vendor/mail/spec/mail/fields/common/common_address_spec.rb +132 -0
  269. data/vendor/mail/spec/mail/fields/common/common_date_spec.rb +25 -0
  270. data/vendor/mail/spec/mail/fields/common/common_field_spec.rb +69 -0
  271. data/vendor/mail/spec/mail/fields/common/common_message_id_spec.rb +30 -0
  272. data/vendor/mail/spec/mail/fields/common/parameter_hash_spec.rb +56 -0
  273. data/vendor/mail/spec/mail/fields/content_description_field_spec.rb +39 -0
  274. data/vendor/mail/spec/mail/fields/content_disposition_field_spec.rb +55 -0
  275. data/vendor/mail/spec/mail/fields/content_id_field_spec.rb +117 -0
  276. data/vendor/mail/spec/mail/fields/content_location_field_spec.rb +46 -0
  277. data/vendor/mail/spec/mail/fields/content_transfer_encoding_field_spec.rb +113 -0
  278. data/vendor/mail/spec/mail/fields/content_type_field_spec.rb +678 -0
  279. data/vendor/mail/spec/mail/fields/date_field_spec.rb +73 -0
  280. data/vendor/mail/spec/mail/fields/envelope_spec.rb +48 -0
  281. data/vendor/mail/spec/mail/fields/from_field_spec.rb +89 -0
  282. data/vendor/mail/spec/mail/fields/in_reply_to_field_spec.rb +62 -0
  283. data/vendor/mail/spec/mail/fields/keywords_field_spec.rb +66 -0
  284. data/vendor/mail/spec/mail/fields/message_id_field_spec.rb +147 -0
  285. data/vendor/mail/spec/mail/fields/mime_version_field_spec.rb +166 -0
  286. data/vendor/mail/spec/mail/fields/received_field_spec.rb +44 -0
  287. data/vendor/mail/spec/mail/fields/references_field_spec.rb +35 -0
  288. data/vendor/mail/spec/mail/fields/reply_to_field_spec.rb +67 -0
  289. data/vendor/mail/spec/mail/fields/resent_bcc_field_spec.rb +66 -0
  290. data/vendor/mail/spec/mail/fields/resent_cc_field_spec.rb +66 -0
  291. data/vendor/mail/spec/mail/fields/resent_date_field_spec.rb +39 -0
  292. data/vendor/mail/spec/mail/fields/resent_from_field_spec.rb +66 -0
  293. data/vendor/mail/spec/mail/fields/resent_message_id_field_spec.rb +24 -0
  294. data/vendor/mail/spec/mail/fields/resent_sender_field_spec.rb +58 -0
  295. data/vendor/mail/spec/mail/fields/resent_to_field_spec.rb +66 -0
  296. data/vendor/mail/spec/mail/fields/return_path_field_spec.rb +52 -0
  297. data/vendor/mail/spec/mail/fields/sender_field_spec.rb +58 -0
  298. data/vendor/mail/spec/mail/fields/structured_field_spec.rb +72 -0
  299. data/vendor/mail/spec/mail/fields/to_field_spec.rb +92 -0
  300. data/vendor/mail/spec/mail/fields/unstructured_field_spec.rb +134 -0
  301. data/vendor/mail/spec/mail/header_spec.rb +578 -0
  302. data/vendor/mail/spec/mail/mail_spec.rb +34 -0
  303. data/vendor/mail/spec/mail/message_spec.rb +1409 -0
  304. data/vendor/mail/spec/mail/mime_messages_spec.rb +435 -0
  305. data/vendor/mail/spec/mail/multipart_report_spec.rb +112 -0
  306. data/vendor/mail/spec/mail/network/delivery_methods/file_delivery_spec.rb +79 -0
  307. data/vendor/mail/spec/mail/network/delivery_methods/sendmail_spec.rb +125 -0
  308. data/vendor/mail/spec/mail/network/delivery_methods/smtp_spec.rb +133 -0
  309. data/vendor/mail/spec/mail/network/delivery_methods/test_mailer_spec.rb +57 -0
  310. data/vendor/mail/spec/mail/network/retriever_methods/pop3_spec.rb +180 -0
  311. data/vendor/mail/spec/mail/network_spec.rb +359 -0
  312. data/vendor/mail/spec/mail/parsers/address_lists_parser_spec.rb +15 -0
  313. data/vendor/mail/spec/mail/parsers/content_transfer_encoding_parser_spec.rb +72 -0
  314. data/vendor/mail/spec/mail/part_spec.rb +129 -0
  315. data/vendor/mail/spec/mail/parts_list_spec.rb +12 -0
  316. data/vendor/mail/spec/mail/round_tripping_spec.rb +44 -0
  317. data/vendor/mail/spec/mail/utilities_spec.rb +327 -0
  318. data/vendor/mail/spec/mail/version_specific/escape_paren_1_8_spec.rb +32 -0
  319. data/vendor/mail/spec/matchers/break_down_to.rb +35 -0
  320. data/vendor/mail/spec/spec_helper.rb +163 -0
  321. metadata +442 -0
@@ -0,0 +1,67 @@
1
+ # encoding: utf-8
2
+ #
3
+ # = Sender Field
4
+ #
5
+ # The Sender field inherits sender StructuredField and handles the Sender: header
6
+ # field in the email.
7
+ #
8
+ # Sending sender to a mail message will instantiate a Mail::Field object that
9
+ # has a SenderField as it's field type. This includes all Mail::CommonAddress
10
+ # module instance metods.
11
+ #
12
+ # Only one Sender field can appear in a header, though it can have multiple
13
+ # addresses and groups of addresses.
14
+ #
15
+ # == Examples:
16
+ #
17
+ # mail = Mail.new
18
+ # mail.sender = 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
19
+ # mail.sender #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
20
+ # mail[:sender] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::SenderField:0x180e1c4
21
+ # mail['sender'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::SenderField:0x180e1c4
22
+ # mail['Sender'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::SenderField:0x180e1c4
23
+ #
24
+ # mail[:sender].encoded #=> 'Sender: Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net\r\n'
25
+ # mail[:sender].decoded #=> 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
26
+ # mail[:sender].addresses #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
27
+ # mail[:sender].formatted #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
28
+ #
29
+ require 'mail/fields/common/common_address'
30
+
31
+ module Mail
32
+ class SenderField < StructuredField
33
+
34
+ include Mail::CommonAddress
35
+
36
+ FIELD_NAME = 'sender'
37
+ CAPITALIZED_FIELD = 'Sender'
38
+
39
+ def initialize(value = nil, charset = 'utf-8')
40
+ self.charset = charset
41
+ super(CAPITALIZED_FIELD, strip_field(FIELD_NAME, value), charset)
42
+ self.parse
43
+ self
44
+ end
45
+
46
+ def addresses
47
+ [address.address]
48
+ end
49
+
50
+ def address
51
+ result = tree.addresses.first
52
+ end
53
+
54
+ def encoded
55
+ do_encode(CAPITALIZED_FIELD)
56
+ end
57
+
58
+ def decoded
59
+ do_decode
60
+ end
61
+
62
+ def default
63
+ address.address
64
+ end
65
+
66
+ end
67
+ end
@@ -0,0 +1,51 @@
1
+ # encoding: utf-8
2
+ require 'mail/fields/common/common_field'
3
+
4
+ module Mail
5
+ # Provides access to a structured header field
6
+ #
7
+ # ===Per RFC 2822:
8
+ # 2.2.2. Structured Header Field Bodies
9
+ #
10
+ # Some field bodies in this standard have specific syntactical
11
+ # structure more restrictive than the unstructured field bodies
12
+ # described above. These are referred to as "structured" field bodies.
13
+ # Structured field bodies are sequences of specific lexical tokens as
14
+ # described in sections 3 and 4 of this standard. Many of these tokens
15
+ # are allowed (according to their syntax) to be introduced or end with
16
+ # comments (as described in section 3.2.3) as well as the space (SP,
17
+ # ASCII value 32) and horizontal tab (HTAB, ASCII value 9) characters
18
+ # (together known as the white space characters, WSP), and those WSP
19
+ # characters are subject to header "folding" and "unfolding" as
20
+ # described in section 2.2.3. Semantic analysis of structured field
21
+ # bodies is given along with their syntax.
22
+ class StructuredField
23
+
24
+ include Mail::CommonField
25
+ include Mail::Utilities
26
+
27
+ def initialize(name = nil, value = nil, charset = nil)
28
+ self.name = name
29
+ self.value = value
30
+ self.charset = charset
31
+ self
32
+ end
33
+
34
+ def charset
35
+ @charset
36
+ end
37
+
38
+ def charset=(val)
39
+ @charset = val
40
+ end
41
+
42
+ def default
43
+ decoded
44
+ end
45
+
46
+ def errors
47
+ []
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+ #
3
+ # subject = "Subject:" unstructured CRLF
4
+ module Mail
5
+ class SubjectField < UnstructuredField
6
+
7
+ FIELD_NAME = 'subject'
8
+ CAPITALIZED_FIELD = "Subject"
9
+
10
+ def initialize(value = nil, charset = 'utf-8')
11
+ self.charset = charset
12
+ super(CAPITALIZED_FIELD, strip_field(FIELD_NAME, value), charset)
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,55 @@
1
+ # encoding: utf-8
2
+ #
3
+ # = To Field
4
+ #
5
+ # The To field inherits to StructuredField and handles the To: header
6
+ # field in the email.
7
+ #
8
+ # Sending to to a mail message will instantiate a Mail::Field object that
9
+ # has a ToField as it's field type. This includes all Mail::CommonAddress
10
+ # module instance metods.
11
+ #
12
+ # Only one To field can appear in a header, though it can have multiple
13
+ # addresses and groups of addresses.
14
+ #
15
+ # == Examples:
16
+ #
17
+ # mail = Mail.new
18
+ # mail.to = 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
19
+ # mail.to #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
20
+ # mail[:to] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::ToField:0x180e1c4
21
+ # mail['to'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::ToField:0x180e1c4
22
+ # mail['To'] #=> '#<Mail::Field:0x180e5e8 @field=#<Mail::ToField:0x180e1c4
23
+ #
24
+ # mail[:to].encoded #=> 'To: Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net\r\n'
25
+ # mail[:to].decoded #=> 'Mikel Lindsaar <mikel@test.lindsaar.net>, ada@test.lindsaar.net'
26
+ # mail[:to].addresses #=> ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net']
27
+ # mail[:to].formatted #=> ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'ada@test.lindsaar.net']
28
+ #
29
+ require 'mail/fields/common/common_address'
30
+
31
+ module Mail
32
+ class ToField < StructuredField
33
+
34
+ include Mail::CommonAddress
35
+
36
+ FIELD_NAME = 'to'
37
+ CAPITALIZED_FIELD = 'To'
38
+
39
+ def initialize(value = nil, charset = 'utf-8')
40
+ self.charset = charset
41
+ super(CAPITALIZED_FIELD, strip_field(FIELD_NAME, value), charset)
42
+ self.parse
43
+ self
44
+ end
45
+
46
+ def encoded
47
+ do_encode(CAPITALIZED_FIELD)
48
+ end
49
+
50
+ def decoded
51
+ do_decode
52
+ end
53
+
54
+ end
55
+ end
@@ -0,0 +1,166 @@
1
+ # encoding: utf-8
2
+ require 'mail/fields/common/common_field'
3
+
4
+ module Mail
5
+ # Provides access to an unstructured header field
6
+ #
7
+ # ===Per RFC 2822:
8
+ # 2.2.1. Unstructured Header Field Bodies
9
+ #
10
+ # Some field bodies in this standard are defined simply as
11
+ # "unstructured" (which is specified below as any US-ASCII characters,
12
+ # except for CR and LF) with no further restrictions. These are
13
+ # referred to as unstructured field bodies. Semantically, unstructured
14
+ # field bodies are simply to be treated as a single line of characters
15
+ # with no further processing (except for header "folding" and
16
+ # "unfolding" as described in section 2.2.3).
17
+ class UnstructuredField
18
+
19
+ include Mail::CommonField
20
+ include Mail::Utilities
21
+
22
+ def initialize(name, value, charset = nil)
23
+ self.charset = charset
24
+ @errors = []
25
+ if charset
26
+ self.charset = charset
27
+ else
28
+ if value.to_s.respond_to?(:encoding)
29
+ self.charset = value.to_s.encoding
30
+ else
31
+ self.charset = $KCODE
32
+ end
33
+ end
34
+ self.name = name
35
+ self.value = value
36
+ self
37
+ end
38
+
39
+ def charset
40
+ @charset
41
+ end
42
+
43
+ def charset=(val)
44
+ @charset = val
45
+ end
46
+
47
+ def errors
48
+ @errors
49
+ end
50
+
51
+ def encoded
52
+ do_encode(self.name)
53
+ end
54
+
55
+ def decoded
56
+ do_decode
57
+ end
58
+
59
+ def default
60
+ decoded
61
+ end
62
+
63
+ def parse # An unstructured field does not parse
64
+ self
65
+ end
66
+
67
+ private
68
+
69
+ def do_encode(name)
70
+ value.nil? ? '' : "#{wrapped_value}\r\n"
71
+ end
72
+
73
+ def do_decode
74
+ value.blank? ? nil : Encodings.decode_encode(value, :decode)
75
+ end
76
+
77
+ # 2.2.3. Long Header Fields
78
+ #
79
+ # Each header field is logically a single line of characters comprising
80
+ # the field name, the colon, and the field body. For convenience
81
+ # however, and to deal with the 998/78 character limitations per line,
82
+ # the field body portion of a header field can be split into a multiple
83
+ # line representation; this is called "folding". The general rule is
84
+ # that wherever this standard allows for folding white space (not
85
+ # simply WSP characters), a CRLF may be inserted before any WSP. For
86
+ # example, the header field:
87
+ #
88
+ # Subject: This is a test
89
+ #
90
+ # can be represented as:
91
+ #
92
+ # Subject: This
93
+ # is a test
94
+ #
95
+ # Note: Though structured field bodies are defined in such a way that
96
+ # folding can take place between many of the lexical tokens (and even
97
+ # within some of the lexical tokens), folding SHOULD be limited to
98
+ # placing the CRLF at higher-level syntactic breaks. For instance, if
99
+ # a field body is defined as comma-separated values, it is recommended
100
+ # that folding occur after the comma separating the structured items in
101
+ # preference to other places where the field could be folded, even if
102
+ # it is allowed elsewhere.
103
+ def wrapped_value # :nodoc:
104
+ @folded_line = []
105
+ @unfolded_line = decoded.to_s.clone
106
+ fold("#{name}: ".length)
107
+ wrap_lines(name, @folded_line)
108
+ end
109
+
110
+ def wrap_lines(name, folded_lines)
111
+ result = []
112
+ index = 0
113
+ result[index] = "#{name}: #{folded_lines.shift}"
114
+ folded_lines.each do |line|
115
+ if (result[index] + line).length < 77
116
+ result[index] << " " + line
117
+ else
118
+ result[index] << "\r\n\t"
119
+ index += 1
120
+ result[index] = line
121
+ end
122
+ end
123
+ result.join
124
+ end
125
+
126
+ def fold(prepend = 0) # :nodoc:
127
+ # Get the last whitespace character, OR we'll just choose
128
+ # 78 if there is no whitespace, or 23 for non ascii:
129
+ # Each QP byte is 6 chars (=0A)
130
+ # Plus 18 for the =?encoding?Q?= ... ?=
131
+ # Plus 2 for the \r\n and 1 for the \t
132
+ # 80 - 2 - 1 - 18 = 59 / 6 ~= 10
133
+ @unfolded_line.ascii_only? ? (limit = 78 - prepend) : (limit = 10 - prepend)
134
+ # find the last white space character within the limit
135
+ if wspp = @unfolded_line.slice(0..limit) =~ /[ \t][^ \t]*$/
136
+ wrap = true
137
+ wspp = limit if wspp == 0
138
+ @folded_line << encode(@unfolded_line.slice!(0...wspp).strip.to_str)
139
+ @folded_line.flatten!
140
+ # if no last whitespace before the limit, find the first
141
+ elsif wspp = @unfolded_line =~ /[ \t][^ \t]/
142
+ wrap = true
143
+ wspp = limit if wspp == 0
144
+ @folded_line << encode(@unfolded_line.slice!(0...wspp).strip.to_str)
145
+ @folded_line.flatten!
146
+ # if no whitespace, don't wrap
147
+ else
148
+ wrap = false
149
+ end
150
+
151
+ if wrap && @unfolded_line.length > limit
152
+ fold
153
+ else
154
+ @folded_line << encode(@unfolded_line)
155
+ @folded_line.flatten!
156
+ end
157
+ end
158
+
159
+ def encode(value)
160
+ value.gsub!("\r", "=0D")
161
+ value.gsub!("\n", "=0A")
162
+ Encodings.q_value_encode(value, @charset).split(" ")
163
+ end
164
+
165
+ end
166
+ end
@@ -0,0 +1,262 @@
1
+ # encoding: utf-8
2
+ module Mail
3
+
4
+ # Provides access to a header object.
5
+ #
6
+ # ===Per RFC2822
7
+ #
8
+ # 2.2. Header Fields
9
+ #
10
+ # Header fields are lines composed of a field name, followed by a colon
11
+ # (":"), followed by a field body, and terminated by CRLF. A field
12
+ # name MUST be composed of printable US-ASCII characters (i.e.,
13
+ # characters that have values between 33 and 126, inclusive), except
14
+ # colon. A field body may be composed of any US-ASCII characters,
15
+ # except for CR and LF. However, a field body may contain CRLF when
16
+ # used in header "folding" and "unfolding" as described in section
17
+ # 2.2.3. All field bodies MUST conform to the syntax described in
18
+ # sections 3 and 4 of this standard.
19
+ class Header
20
+ include Patterns
21
+ include Utilities
22
+ include Enumerable
23
+
24
+ # Creates a new header object.
25
+ #
26
+ # Accepts raw text or nothing. If given raw text will attempt to parse
27
+ # it and split it into the various fields, instantiating each field as
28
+ # it goes.
29
+ #
30
+ # If it finds a field that should be a structured field (such as content
31
+ # type), but it fails to parse it, it will simply make it an unstructured
32
+ # field and leave it alone. This will mean that the data is preserved but
33
+ # no automatic processing of that field will happen. If you find one of
34
+ # these cases, please make a patch and send it in, or at the least, send
35
+ # me the example so we can fix it.
36
+ def initialize(header_text = nil, charset = nil)
37
+ @errors = []
38
+ @charset = charset
39
+ self.raw_source = header_text.to_crlf
40
+ split_header if header_text
41
+ end
42
+
43
+ # The preserved raw source of the header as you passed it in, untouched
44
+ # for your Regexing glory.
45
+ def raw_source
46
+ @raw_source
47
+ end
48
+
49
+ # Returns an array of all the fields in the header in order that they
50
+ # were read in.
51
+ def fields
52
+ @fields ||= FieldList.new
53
+ end
54
+
55
+ # 3.6. Field definitions
56
+ #
57
+ # It is important to note that the header fields are not guaranteed to
58
+ # be in a particular order. They may appear in any order, and they
59
+ # have been known to be reordered occasionally when transported over
60
+ # the Internet. However, for the purposes of this standard, header
61
+ # fields SHOULD NOT be reordered when a message is transported or
62
+ # transformed. More importantly, the trace header fields and resent
63
+ # header fields MUST NOT be reordered, and SHOULD be kept in blocks
64
+ # prepended to the message. See sections 3.6.6 and 3.6.7 for more
65
+ # information.
66
+ #
67
+ # Populates the fields container with Field objects in the order it
68
+ # receives them in.
69
+ #
70
+ # Acceps an array of field string values, for example:
71
+ #
72
+ # h = Header.new
73
+ # h.fields = ['From: mikel@me.com', 'To: bob@you.com']
74
+ def fields=(unfolded_fields)
75
+ @fields = Mail::FieldList.new
76
+ unfolded_fields.each do |field|
77
+
78
+ field = Field.new(field, nil, charset)
79
+ field.errors.each { |error| self.errors << error }
80
+ selected = select_field_for(field.name)
81
+
82
+ if selected.any? && limited_field?(field.name)
83
+ selected.first.update(field.name, field.value)
84
+ else
85
+ @fields << field
86
+ end
87
+ end
88
+
89
+ end
90
+
91
+ def errors
92
+ @errors
93
+ end
94
+
95
+ # 3.6. Field definitions
96
+ #
97
+ # The following table indicates limits on the number of times each
98
+ # field may occur in a message header as well as any special
99
+ # limitations on the use of those fields. An asterisk next to a value
100
+ # in the minimum or maximum column indicates that a special restriction
101
+ # appears in the Notes column.
102
+ #
103
+ # <snip table from 3.6>
104
+ #
105
+ # As per RFC, many fields can appear more than once, we will return a string
106
+ # of the value if there is only one header, or if there is more than one
107
+ # matching header, will return an array of values in order that they appear
108
+ # in the header ordered from top to bottom.
109
+ #
110
+ # Example:
111
+ #
112
+ # h = Header.new
113
+ # h.fields = ['To: mikel@me.com', 'X-Mail-SPAM: 15', 'X-Mail-SPAM: 20']
114
+ # h['To'] #=> 'mikel@me.com'
115
+ # h['X-Mail-SPAM'] #=> ['15', '20']
116
+ def [](name)
117
+ name = dasherize(name).downcase
118
+ selected = select_field_for(name)
119
+ case
120
+ when selected.length > 1
121
+ selected.map { |f| f }
122
+ when !selected.blank?
123
+ selected.first
124
+ else
125
+ nil
126
+ end
127
+ end
128
+
129
+ # Sets the FIRST matching field in the header to passed value, or deletes
130
+ # the FIRST field matched from the header if passed nil
131
+ #
132
+ # Example:
133
+ #
134
+ # h = Header.new
135
+ # h.fields = ['To: mikel@me.com', 'X-Mail-SPAM: 15', 'X-Mail-SPAM: 20']
136
+ # h['To'] = 'bob@you.com'
137
+ # h['To'] #=> 'bob@you.com'
138
+ # h['X-Mail-SPAM'] = '10000'
139
+ # h['X-Mail-SPAM'] # => ['15', '20', '10000']
140
+ # h['X-Mail-SPAM'] = nil
141
+ # h['X-Mail-SPAM'] # => nil
142
+ def []=(name, value)
143
+ name = dasherize(name)
144
+ fn = name.downcase
145
+ selected = select_field_for(fn)
146
+
147
+ case
148
+ # User wants to delete the field
149
+ when !selected.blank? && value == nil
150
+ fields.delete_if { |f| selected.include?(f) }
151
+
152
+ # User wants to change the field
153
+ when !selected.blank? && limited_field?(fn)
154
+ selected.first.update(fn, value)
155
+
156
+ # User wants to create the field
157
+ else
158
+ # Need to insert in correct order for trace fields
159
+ self.fields << Field.new(name.to_s, value, charset)
160
+ end
161
+ end
162
+
163
+ def charset
164
+ if self['content_type'] && self['content_type'].parameters
165
+ self['content_type'].parameters['charset']
166
+ else
167
+ @charset
168
+ end
169
+ end
170
+
171
+ def charset=(val)
172
+ if self['content_type']
173
+ self['content_type'].parameters['charset'] = val
174
+ end
175
+ @charset = val
176
+ end
177
+
178
+ LIMITED_FIELDS = %w[ date from sender reply-to to cc bcc
179
+ message-id in-reply-to references subject
180
+ return-path content-type mime-version
181
+ content-transfer-encoding content-description
182
+ content-id content-disposition content-location]
183
+
184
+ def encoded
185
+ buffer = ''
186
+ fields.each do |field|
187
+ buffer << field.encoded
188
+ end
189
+ buffer
190
+ end
191
+
192
+ def to_s
193
+ encoded
194
+ end
195
+
196
+ def decoded
197
+ raise NoMethodError, 'Can not decode an entire header as there could be character set conflicts, try calling #decoded on the various fields.'
198
+ end
199
+
200
+ def field_summary
201
+ fields.map { |f| "<#{f.name}: #{f.value}>" }.join(", ")
202
+ end
203
+
204
+ # Returns true if the header has a Message-ID defined (empty or not)
205
+ def has_message_id?
206
+ !fields.select { |f| f.responsible_for?('Message-ID') }.empty?
207
+ end
208
+
209
+ # Returns true if the header has a Content-ID defined (empty or not)
210
+ def has_content_id?
211
+ !fields.select { |f| f.responsible_for?('Content-ID') }.empty?
212
+ end
213
+
214
+ # Returns true if the header has a Date defined (empty or not)
215
+ def has_date?
216
+ !fields.select { |f| f.responsible_for?('Date') }.empty?
217
+ end
218
+
219
+ # Returns true if the header has a MIME version defined (empty or not)
220
+ def has_mime_version?
221
+ !fields.select { |f| f.responsible_for?('Mime-Version') }.empty?
222
+ end
223
+
224
+ private
225
+
226
+ def raw_source=(val)
227
+ @raw_source = val
228
+ end
229
+
230
+ # 2.2.3. Long Header Fields
231
+ #
232
+ # The process of moving from this folded multiple-line representation
233
+ # of a header field to its single line representation is called
234
+ # "unfolding". Unfolding is accomplished by simply removing any CRLF
235
+ # that is immediately followed by WSP. Each header field should be
236
+ # treated in its unfolded form for further syntactic and semantic
237
+ # evaluation.
238
+ def unfold(string)
239
+ string.gsub(/#{CRLF}#{WSP}+/, ' ').gsub(/#{WSP}+/, ' ')
240
+ end
241
+
242
+ # Returns the header with all the folds removed
243
+ def unfolded_header
244
+ @unfolded_header ||= unfold(raw_source)
245
+ end
246
+
247
+ # Splits an unfolded and line break cleaned header into individual field
248
+ # strings.
249
+ def split_header
250
+ self.fields = unfolded_header.split(CRLF)
251
+ end
252
+
253
+ def select_field_for(name)
254
+ fields.select { |f| f.responsible_for?(name.to_s) }
255
+ end
256
+
257
+ def limited_field?(name)
258
+ LIMITED_FIELDS.include?(name.to_s.downcase)
259
+ end
260
+
261
+ end
262
+ end