rack-mail_exception 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
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,134 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Mail::UnstructuredField do
5
+
6
+ describe "initialization" do
7
+
8
+ it "should be instantiated" do
9
+ doing {Mail::UnstructuredField.new("Name", "Value")}.should_not raise_error
10
+ end
11
+
12
+ end
13
+
14
+ describe "manipulation" do
15
+
16
+ before(:each) do
17
+ @field = Mail::UnstructuredField.new("Subject", "Hello Frank")
18
+ end
19
+
20
+ it "should allow us to set a text value at initialization" do
21
+ doing{Mail::UnstructuredField.new("Subject", "Value")}.should_not raise_error
22
+ end
23
+
24
+ it "should provide access to the text of the field once set" do
25
+ @field.value.should == "Hello Frank"
26
+ end
27
+
28
+ it "should provide a means to change the value" do
29
+ @field.value = "Goodbye Frank"
30
+ @field.value.should == "Goodbye Frank"
31
+ end
32
+ end
33
+
34
+ describe "displaying encoded field and decoded value" do
35
+
36
+ before(:each) do
37
+ @field = Mail::UnstructuredField.new("Subject", "Hello Frank")
38
+ end
39
+
40
+ it "should provide a to_s function that returns the field name and value" do
41
+ @field.value.should == "Hello Frank"
42
+ end
43
+
44
+ it "should return '' on to_s if there is no value" do
45
+ @field.value = nil
46
+ @field.encoded.should == ''
47
+ end
48
+
49
+ it "should give an encoded value ready to insert into an email" do
50
+ @field.encoded.should == "Subject: Hello Frank\r\n"
51
+ end
52
+
53
+ it "should return nil on encoded if it has no value" do
54
+ @field.value = nil
55
+ @field.encoded.should == ''
56
+ end
57
+
58
+ it "should give an decoded value ready to insert into an email" do
59
+ @field.decoded.should == "Hello Frank"
60
+ end
61
+
62
+ it "should return a nil on decoded if it has no value" do
63
+ @field.value = nil
64
+ @field.decoded.should == nil
65
+ end
66
+
67
+ it "should just add the CRLF at the end of the line" do
68
+ @field = Mail::SubjectField.new("Subject: =?utf-8?Q?testing_testing_=D6=A4?=")
69
+ result = "Subject: testing testing =?UTF8?Q?_=D6=A4=?=\r\n"
70
+ @field.encoded.gsub("UTF-8", "UTF8").should == result
71
+ @field.decoded.should == "testing testing \326\244"
72
+ end
73
+
74
+ end
75
+
76
+ describe "folding" do
77
+
78
+ it "should not fold itself if it is 78 chracters long" do
79
+ @field = Mail::UnstructuredField.new("Subject", "This is a subject header message that is _exactly_ 78 characters....")
80
+ @field.encoded.should == "Subject: This is a subject header message that is _exactly_ 78 characters....\r\n"
81
+ end
82
+
83
+ it "should fold itself if it is 79 chracters long" do
84
+ @field = Mail::UnstructuredField.new("Subject", "This is a subject header message that is _exactly_ 79 characters long")
85
+ result = "Subject: This is a subject header message that is _exactly_ 79 characters\r\n\tlong\r\n"
86
+ @field.encoded.should == result
87
+ end
88
+
89
+ it "should fold itself if it is 997 chracters long" do
90
+ @field = Mail::UnstructuredField.new("Subject", "This is a subject header message that is going to be 997 characters long. This is a subject header message that is going to be 997 characters long. This is a subject header message that is going to be 997 characters long. This is a subject header message that is going to be 997 characters long. This is a subject header message that is going to be 997 characters long. This is a subject header message that is going to be 997 characters long. This is a subject header message that is going to be 997 characters long. This is a subject header message that is going to be 997 characters long. This is a subject header message that is going to be 997 characters long. This is a subject header message that is going to be 997 characters long. This is a subject header message that is going to be 997 characters long. This is a subject header message that is going to be 997 characters long. This is a subject header message that is going to be 997 characters long. And this makes it 997....")
91
+ lines = @field.encoded.split("\r\n\t")
92
+ lines.each { |line| line.length.should < 78 }
93
+ end
94
+
95
+ it "should fold itself if it is 998 characters long" do
96
+ value = "This is a subject header message that is going to be 998 characters long. This is a subject header message that is going to be 998 characters long. This is a subject header message that is going to be 998 characters long. This is a subject header message that is going to be 998 characters long. This is a subject header message that is going to be 998 characters long. This is a subject header message that is going to be 998 characters long. This is a subject header message that is going to be 998 characters long. This is a subject header message that is going to be 998 characters long. This is a subject header message that is going to be 998 characters long. This is a subject header message that is going to be 998 characters long. This is a subject header message that is going to be 998 characters long. This is a subject header message that is going to be 998 characters long. This is a subject header message that is going to be 998 characters long. And this makes it 998 long"
97
+ @field = Mail::UnstructuredField.new("Subject", value)
98
+ lines = @field.encoded.split("\r\n\t")
99
+ lines.each { |line| line.length.should < 78 }
100
+ end
101
+
102
+ it "should fold itself if it is 999 characters long" do
103
+ value = "This is a subject header message that is going to be 999 characters long. This is a subject header message that is going to be 999 characters long. This is a subject header message that is going to be 999 characters long. This is a subject header message that is going to be 999 characters long. This is a subject header message that is going to be 999 characters long. This is a subject header message that is going to be 999 characters long. This is a subject header message that is going to be 999 characters long. This is a subject header message that is going to be 999 characters long. This is a subject header message that is going to be 999 characters long. This is a subject header message that is going to be 999 characters long. This is a subject header message that is going to be 999 characters long. This is a subject header message that is going to be 999 characters long. This is a subject header message that is going to be 999 characters long. And this makes it 999 long."
104
+ @field = Mail::UnstructuredField.new("Subject", value)
105
+ lines = @field.encoded.split("\r\n\t")
106
+ lines.each { |line| line.length.should < 78 }
107
+ end
108
+
109
+ it "should fold itself if it is non us-ascii" do
110
+ @original = $KCODE if RUBY_VERSION < '1.9'
111
+ string = "This is あ really long string This is あ really long string This is あ really long string This is あ really long string This is あ really long string"
112
+ @field = Mail::UnstructuredField.new("Subject", string)
113
+ if string.respond_to?(:force_encoding)
114
+ string = string.force_encoding('UTF-8')
115
+ else
116
+ $KCODE = 'u'
117
+ end
118
+ result = "Subject: This =?UTF8?Q?is_=E3=81=82=?= really long string\r\n\t=?UTF8?Q?This_is_=E3=81=82=?= really long string\r\n\t=?UTF8?Q?This_is_=E3=81=82=?= really long string\r\n\t=?UTF8?Q?This_is_=E3=81=82=?= really long string\r\n\t=?UTF8?Q?This_is_=E3=81=82=?= really long string\r\n"
119
+ @field.encoded.gsub("UTF-8", "UTF8").should == result
120
+ @field.decoded.should == string
121
+ $KCODE = @original if RUBY_VERSION < '1.9'
122
+ end
123
+
124
+ end
125
+
126
+ describe "encoding non QP safe chars" do
127
+ it "should encode an ascii string that has carriage returns if asked to" do
128
+ result = "Subject: =0Aasdf=0A\r\n"
129
+ @field = Mail::UnstructuredField.new("Subject", "\nasdf\n")
130
+ @field.encoded.should == "Subject: =0Aasdf=0A\r\n"
131
+ end
132
+ end
133
+
134
+ end
@@ -0,0 +1,578 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Mail::Header do
5
+
6
+ describe "initialization" do
7
+
8
+ it "should instantiate empty" do
9
+ doing { Mail::Header.new }.should_not raise_error
10
+ end
11
+
12
+ it "should instantiate with a string passed in" do
13
+ doing { Mail::Header.new("To: Mikel\r\nFrom: bob\r\n") }.should_not raise_error
14
+ end
15
+
16
+ end
17
+
18
+ describe "instance methods" do
19
+
20
+ it "should save away the raw source of the header that it is passed" do
21
+ header = Mail::Header.new("To: Mikel\r\nFrom: bob\r\n")
22
+ header.raw_source.should == "To: Mikel\r\nFrom: bob\r\n"
23
+ end
24
+
25
+ it "should say if it has a message_id field defined" do
26
+ header = Mail::Header.new("To: Mikel\r\nFrom: bob\r\n")
27
+ header.should_not be_has_message_id
28
+ end
29
+
30
+ it "should say if it has a message_id field defined" do
31
+ header = Mail::Header.new("To: Mikel\r\nFrom: bob\r\nMessage-ID: 1234")
32
+ header.should be_has_message_id
33
+ end
34
+
35
+ it "should say if it has a content_id field defined" do
36
+ header = Mail::Header.new("To: Mikel\r\nFrom: bob\r\n")
37
+ header.should_not be_has_content_id
38
+ end
39
+
40
+ it "should say if it has a content_id field defined" do
41
+ header = Mail::Header.new("To: Mikel\r\nFrom: bob\r\nContent-ID: <1234@me.com>")
42
+ header.should be_has_content_id
43
+ end
44
+
45
+ it "should know it's own charset" do
46
+ header = Mail::Header.new("To: Mikel\r\nFrom: bob\r\nContent-ID: <1234@me.com>")
47
+ header.charset.should == nil
48
+ end
49
+
50
+ it "should know it's own charset if set" do
51
+ header = Mail::Header.new
52
+ header['content-type'] = 'text/plain; charset=utf-8'
53
+ header.charset.should == 'utf-8'
54
+ end
55
+
56
+ end
57
+
58
+ describe "creating fields" do
59
+ it "should recognise a bcc field" do
60
+ header = Mail::Header.new
61
+ header['bcc'] = 'mikel@test.lindsaar.net'
62
+ header['bcc'].field.class.should == Mail::BccField
63
+ end
64
+
65
+ it "should recognise a cc field" do
66
+ header = Mail::Header.new
67
+ header['cc'] = 'mikel@test.lindsaar.net'
68
+ header['cc'].field.class.should == Mail::CcField
69
+ end
70
+
71
+ it "should recognise a content-description field" do
72
+ header = Mail::Header.new
73
+ header['content-description'] = 'Text'
74
+ header['content-description'].field.class.should == Mail::ContentDescriptionField
75
+ end
76
+
77
+ it "should recognise a content-disposition field" do
78
+ header = Mail::Header.new
79
+ header['content-disposition'] = 'attachment; filename=File'
80
+ header['content-disposition'].field.class.should == Mail::ContentDispositionField
81
+ end
82
+
83
+ it "should recognise a content-id field" do
84
+ header = Mail::Header.new
85
+ header['content-id'] = '<1234@test.lindsaar.net>'
86
+ header['content-id'].field.class.should == Mail::ContentIdField
87
+ end
88
+
89
+ it "should recognise a content-transfer-encoding field" do
90
+ header = Mail::Header.new
91
+ header['content-transfer-encoding'] = '7bit'
92
+ header['content-transfer-encoding'].field.class.should == Mail::ContentTransferEncodingField
93
+ end
94
+
95
+ it "should recognise a content-type field" do
96
+ header = Mail::Header.new
97
+ header['content-type'] = 'text/plain'
98
+ header['content-type'].field.class.should == Mail::ContentTypeField
99
+ end
100
+
101
+ it "should recognise a date field" do
102
+ header = Mail::Header.new
103
+ header['date'] = 'Fri, 21 Nov 1997 09:55:06 -0600'
104
+ header['date'].field.class.should == Mail::DateField
105
+ end
106
+
107
+ it "should recognise a from field" do
108
+ header = Mail::Header.new
109
+ header['from'] = 'mikel@test.lindsaar.net'
110
+ header['from'].field.class.should == Mail::FromField
111
+ end
112
+
113
+ it "should recognise a in-reply-to field" do
114
+ header = Mail::Header.new
115
+ header['in-reply-to'] = '<1234@test.lindsaar.net>'
116
+ header['in-reply-to'].field.class.should == Mail::InReplyToField
117
+ end
118
+
119
+ it "should recognise a keywords field" do
120
+ header = Mail::Header.new
121
+ header['keywords'] = 'mikel test lindsaar net'
122
+ header['keywords'].field.class.should == Mail::KeywordsField
123
+ end
124
+
125
+ it "should recognise a message-id field" do
126
+ header = Mail::Header.new
127
+ header['message-id'] = '<1234@test.lindsaar.net>'
128
+ header['message-id'].field.class.should == Mail::MessageIdField
129
+ end
130
+
131
+ it "should recognise a mime-version field" do
132
+ header = Mail::Header.new
133
+ header['mime-version'] = '1.0'
134
+ header['mime-version'].field.class.should == Mail::MimeVersionField
135
+ end
136
+
137
+ it "should recognise a received field" do
138
+ header = Mail::Header.new
139
+ header['received'] = 'from xxx.xxxx.xxx by xxx.xxxx.xxx with ESMTP id C1B953B4CB6 for <xxxxx@Exxx.xxxx.xxx>; Tue, 10 May 2005 15:27:05 -0500'
140
+ header['received'].field.class.should == Mail::ReceivedField
141
+ end
142
+
143
+ it "should recognise a references field" do
144
+ header = Mail::Header.new
145
+ header['references'] = '<1234@test.lindsaar.net>'
146
+ header['references'].field.class.should == Mail::ReferencesField
147
+ end
148
+
149
+ it "should recognise a reply-to field" do
150
+ header = Mail::Header.new
151
+ header['reply-to'] = 'mikel@test.lindsaar.net'
152
+ header['reply-to'].field.class.should == Mail::ReplyToField
153
+ end
154
+
155
+ it "should recognise a resent-bcc field" do
156
+ header = Mail::Header.new
157
+ header['resent-bcc'] = 'mikel@test.lindsaar.net'
158
+ header['resent-bcc'].field.class.should == Mail::ResentBccField
159
+ end
160
+
161
+ it "should recognise a resent-cc field" do
162
+ header = Mail::Header.new
163
+ header['resent-cc'] = 'mikel@test.lindsaar.net'
164
+ header['resent-cc'].field.class.should == Mail::ResentCcField
165
+ end
166
+
167
+ it "should recognise a resent-date field" do
168
+ header = Mail::Header.new
169
+ header['resent-date'] = 'Fri, 21 Nov 1997 09:55:06 -0600'
170
+ header['resent-date'].field.class.should == Mail::ResentDateField
171
+ end
172
+
173
+ it "should recognise a resent-from field" do
174
+ header = Mail::Header.new
175
+ header['resent-from'] = 'mikel@test.lindsaar.net'
176
+ header['resent-from'].field.class.should == Mail::ResentFromField
177
+ end
178
+
179
+ it "should recognise a resent-message-id field" do
180
+ header = Mail::Header.new
181
+ header['resent-message-id'] = '<1234@mail.baci.local>'
182
+ header['resent-message-id'].field.class.should == Mail::ResentMessageIdField
183
+ end
184
+
185
+ it "should recognise a resent-sender field" do
186
+ header = Mail::Header.new
187
+ header['resent-sender'] = 'mikel@test.lindsaar.net'
188
+ header['resent-sender'].field.class.should == Mail::ResentSenderField
189
+ end
190
+
191
+ it "should recognise a resent-to field" do
192
+ header = Mail::Header.new
193
+ header['resent-to'] = 'mikel@test.lindsaar.net'
194
+ header['resent-to'].field.class.should == Mail::ResentToField
195
+ end
196
+
197
+ it "should recognise a return-path field" do
198
+ header = Mail::Header.new
199
+ header['return-path'] = '<mikel@me.com>'
200
+ header['return-path'].field.class.should == Mail::ReturnPathField
201
+ end
202
+
203
+ it "should recognise a sender field" do
204
+ header = Mail::Header.new
205
+ header['sender'] = 'mikel@test.lindsaar.net'
206
+ header['sender'].field.class.should == Mail::SenderField
207
+ end
208
+
209
+ it "should recognise a to field" do
210
+ header = Mail::Header.new
211
+ header['to'] = 'mikel@test.lindsaar.net'
212
+ header['to'].field.class.should == Mail::ToField
213
+ end
214
+
215
+ it "should maintain header case" do
216
+ header = Mail::Header.new
217
+ header['User-Agent'] = 'My funky mailer'
218
+ header.encoded.should match(/^User-Agent: /)
219
+ header.encoded.should_not match(/^user-agent: /)
220
+ end
221
+
222
+ end
223
+
224
+
225
+ describe "parsing" do
226
+
227
+ it "should split the header into separate fields" do
228
+ header = Mail::Header.new("To: Mikel\r\nFrom: bob\r\n")
229
+ header.fields.length.should == 2
230
+ end
231
+
232
+ it "should not split a wrapped header in two" do
233
+ header = Mail::Header.new("To: mikel lindsaar\r\n\t<mikel@lindsaar>\r\nFrom: bob\r\nSubject: This is\r\n a long\r\n\t \t \t \t badly formatted \r\n \t\t \t field")
234
+ header.fields.length.should == 3
235
+ end
236
+
237
+ # Header fields are lines composed of a field name, followed by a colon
238
+ # (":"), followed by a field body, and terminated by CRLF. A field
239
+ # name MUST be composed of printable US-ASCII characters (i.e.,
240
+ # characters that have values between 33 and 126, inclusive), except
241
+ # colon.
242
+ it "should accept any valid header field name" do
243
+ test_name = ascii.reject { |c| c == ':' }.join
244
+ doing { Mail::Header.new("#{test_name}: This is a crazy name") }.should_not raise_error
245
+ end
246
+
247
+ # A field body may be composed of any US-ASCII characters,
248
+ # except for CR and LF. However, a field body may contain CRLF when
249
+ # used in header "folding" and "unfolding" as described in section
250
+ # 2.2.3.
251
+ it "should accept any valid header field value" do
252
+ test_value = ascii.reject { |c| c == ':' }
253
+ test_value << ' '
254
+ test_value << '\r\n'
255
+ doing {Mail::Header.new("header: #{test_value}")}.should_not raise_error
256
+ end
257
+
258
+ it "should split each field into an name and value" do
259
+ header = Mail::Header.new("To: Mikel\r\nFrom: bob\r\n")
260
+ header.fields[0].name.should == "From"
261
+ header.fields[0].value.should == "bob"
262
+ header.fields[1].name.should == "To"
263
+ header.fields[1].value.should == "Mikel"
264
+ end
265
+
266
+ it "should split each field into an name and value - even if whitespace is missing" do
267
+ header = Mail::Header.new("To: Mikel\r\nFrom:bob\r\n")
268
+ header.fields[0].name.should == "From"
269
+ header.fields[0].value.should == "bob"
270
+ header.fields[1].name.should == "To"
271
+ header.fields[1].value.should == "Mikel"
272
+ end
273
+
274
+ it "should preserve the order of the fields it is given" do
275
+ header = Mail::Header.new
276
+ header.fields = ['From: mikel@me.com', 'To: bob@you.com', 'Subject: This is a badly formed email']
277
+ header.fields[0].name.should == 'From'
278
+ header.fields[1].name.should == 'To'
279
+ header.fields[2].name.should == 'Subject'
280
+ end
281
+
282
+ it "should allow you to reference each field and value by literal string name" do
283
+ header = Mail::Header.new("To: Mikel\r\nFrom: bob\r\n")
284
+ header['To'].value.should == "Mikel"
285
+ header['From'].value.should == "bob"
286
+ end
287
+
288
+ it "should return an array of fields if there is more than one match" do
289
+ header = Mail::Header.new
290
+ header.fields = ['From: mikel@me.com', 'X-Mail-SPAM: 15', 'X-Mail-SPAM: 23']
291
+ header['X-Mail-SPAM'].map { |x| x.value }.should == ['15', '23']
292
+ end
293
+
294
+ it "should return nil if no value in the header" do
295
+ header = Mail::Header.new("To: Mikel\r\nFrom: bob\r\n")
296
+ header['Subject'].should be_nil
297
+ end
298
+
299
+ it "should add a new field if the field does not exist" do
300
+ header = Mail::Header.new("To: Mikel\r\nFrom: bob\r\n")
301
+ header['Subject'] = "G'Day!"
302
+ header['Subject'].value.should == "G'Day!"
303
+ end
304
+
305
+ it "should allow you to pass in an array of raw fields" do
306
+ header = Mail::Header.new
307
+ header.fields = ['From: mikel@test.lindsaar.net', 'To: bob@you.com']
308
+ header['To'].value.should == 'bob@you.com'
309
+ header['From'].value.should == 'mikel@test.lindsaar.net'
310
+ end
311
+
312
+ it "should reset the value of a single-only field if it already exists" do
313
+ header = Mail::Header.new("To: Mikel\r\nFrom: bob\r\n")
314
+ header['To'] = 'George'
315
+ header['To'].value.should == "George"
316
+ end
317
+
318
+ it "should allow you to delete a field by setting it to nil" do
319
+ header = Mail::Header.new
320
+ header.fields = ['To: bob@you.com']
321
+ header.fields.length.should == 1
322
+ header['To'] = nil
323
+ header.fields.length.should == 0
324
+ end
325
+
326
+ it "should delete all matching fields found if there are multiple options" do
327
+ header = Mail::Header.new
328
+ header.fields = ['X-SPAM: 1000', 'X-SPAM: 20']
329
+ header['X-SPAM'] = nil
330
+ header.fields.length.should == 0
331
+ end
332
+
333
+ # Handle empty X-Optional header from Microsoft Exchange
334
+ it "should handle an empty X-* header value" do
335
+ header = Mail::Header.new("X-MS-TNEF-Correlator:\r\n")
336
+ header.fields.length.should == 1
337
+ header['X-MS-TNEF-Correlator'].decoded.should == nil
338
+ header['X-MS-TNEF-Correlator'].encoded.should == "X-MS-TNEF-Correlator: \r\n"
339
+ end
340
+
341
+ it "should accept X- option fields from MS-Exchange" do
342
+ header = Mail::Header.new("X-Ms-Has-Attach:\r\nX-MS-TNEF-Correlator: \r\n")
343
+ header.fields.length.should == 2
344
+ header['X-Ms-Has-Attach'].decoded.should == nil
345
+ header['X-Ms-Has-Attach'].encoded.should == "X-Ms-Has-Attach: \r\n"
346
+ header['X-MS-TNEF-Correlator'].decoded.should == nil
347
+ header['X-MS-TNEF-Correlator'].encoded.should == "X-MS-TNEF-Correlator: \r\n"
348
+ end
349
+
350
+ it "should return nil if asked for the value of a non existent field" do
351
+ header = Mail::Header.new
352
+ header['Bobs-Field'].should == nil
353
+ end
354
+
355
+ it "should allow you to replace a from field" do
356
+ header = Mail::Header.new
357
+ header['From'].should == nil
358
+ header['From'] = 'mikel@test.lindsaar.net'
359
+ header['From'].decoded.should == 'mikel@test.lindsaar.net'
360
+ header['From'] = 'bob@test.lindsaar.net'
361
+ header['From'].decoded.should == 'bob@test.lindsaar.net'
362
+ end
363
+
364
+ it "should maintain the class of the field" do
365
+ header = Mail::Header.new
366
+ header['From'] = 'mikel@test.lindsaar.net'
367
+ header['From'].field.class.should == Mail::FromField
368
+ header['From'] = 'bob@test.lindsaar.net'
369
+ header['From'].field.class.should == Mail::FromField
370
+ end
371
+
372
+ end
373
+
374
+ describe "folding and unfolding" do
375
+
376
+ it "should unfold a header" do
377
+ header = Mail::Header.new("To: Mikel,\r\n Lindsaar, Bob")
378
+ header['To'].value.should == 'Mikel, Lindsaar, Bob'
379
+ end
380
+
381
+ it "should remove multiple spaces during unfolding a header" do
382
+ header = Mail::Header.new("To: Mikel,\r\n Lindsaar, Bob")
383
+ header['To'].value.should == 'Mikel, Lindsaar, Bob'
384
+ end
385
+
386
+ it "should handle a crazy long folded header" do
387
+ header_text =<<HERE
388
+ Received: from [127.0.220.158] (helo=fg-out-1718.google.com)
389
+ by smtp.totallyrandom.com with esmtp (Exim 4.68)
390
+ (envelope-from <stuff+caf_=support=aaa.somewhere.com@gmail.com>)
391
+ id 1K4JeQ-0005Nd-Ij
392
+ for support@aaa.somewhere.com; Thu, 05 Jun 2008 10:53:29 -0700
393
+ HERE
394
+ header = Mail::Header.new(header_text.gsub(/\n/, "\r\n"))
395
+ header['Received'].value.should == 'from [127.0.220.158] (helo=fg-out-1718.google.com) by smtp.totallyrandom.com with esmtp (Exim 4.68) (envelope-from <stuff+caf_=support=aaa.somewhere.com@gmail.com>) id 1K4JeQ-0005Nd-Ij for support@aaa.somewhere.com; Thu, 05 Jun 2008 10:53:29 -0700'
396
+ end
397
+
398
+ it "should convert all lonesome LFs to CRLF" do
399
+ header_text =<<HERE
400
+ Received: from [127.0.220.158] (helo=fg-out-1718.google.com)
401
+ by smtp.totallyrandom.com with esmtp (Exim 4.68)
402
+ (envelope-from <stuff+caf_=support=aaa.somewhere.com@gmail.com>)
403
+ id 1K4JeQ-0005Nd-Ij
404
+ for support@aaa.somewhere.com; Thu, 05 Jun 2008 10:53:29 -0700
405
+ HERE
406
+ header = Mail::Header.new(header_text.gsub(/\n/, "\n"))
407
+ header['Received'].value.should == 'from [127.0.220.158] (helo=fg-out-1718.google.com) by smtp.totallyrandom.com with esmtp (Exim 4.68) (envelope-from <stuff+caf_=support=aaa.somewhere.com@gmail.com>) id 1K4JeQ-0005Nd-Ij for support@aaa.somewhere.com; Thu, 05 Jun 2008 10:53:29 -0700'
408
+ end
409
+
410
+ it "should convert all lonesome CRs to CRLF" do
411
+ header_text =<<HERE
412
+ Received: from [127.0.220.158] (helo=fg-out-1718.google.com)
413
+ by smtp.totallyrandom.com with esmtp (Exim 4.68)
414
+ (envelope-from <stuff+caf_=support=aaa.somewhere.com@gmail.com>)
415
+ id 1K4JeQ-0005Nd-Ij
416
+ for support@aaa.somewhere.com; Thu, 05 Jun 2008 10:53:29 -0700
417
+ HERE
418
+ header = Mail::Header.new(header_text.gsub(/\n/, "\r"))
419
+ header['Received'].value.should == 'from [127.0.220.158] (helo=fg-out-1718.google.com) by smtp.totallyrandom.com with esmtp (Exim 4.68) (envelope-from <stuff+caf_=support=aaa.somewhere.com@gmail.com>) id 1K4JeQ-0005Nd-Ij for support@aaa.somewhere.com; Thu, 05 Jun 2008 10:53:29 -0700'
420
+ end
421
+
422
+ end
423
+
424
+ describe "error handling" do
425
+ it "should collect up any of its fields' errors" do
426
+ header = Mail::Header.new("Content-Transfer-Encoding: vlad\r\nReply-To: a b b")
427
+ header.errors.should_not be_blank
428
+ header.errors.size.should == 2
429
+ header.errors[0][0].should == 'Content-Transfer-Encoding'
430
+ header.errors[0][1].should == 'vlad'
431
+ header.errors[1][0].should == 'Reply-To'
432
+ header.errors[1][1].should == 'a b b'
433
+ end
434
+ end
435
+
436
+ describe "handling date fields with multiple values" do
437
+ it "should know which fields can only appear once" do
438
+ %w[ date ].each do |field|
439
+ header = Mail::Header.new
440
+ header[field] = "Thu, 05 Jun 2008 10:53:29 -0700"
441
+ header[field] = "Mon, 15 Nov 2010 11:05:29 -1100"
442
+ header[field].value.should == "Mon, 15 Nov 2010 11:05:29 -1100"
443
+ end
444
+ end
445
+
446
+ it "should know which fields can only appear once" do
447
+ %w[ from sender reply-to to cc bcc ].each do |field|
448
+ header = Mail::Header.new
449
+ header[field] = "mikel@test.lindsaar.net"
450
+ header[field] = "ada@test.lindsaar.net"
451
+ header[field].value.should == "ada@test.lindsaar.net"
452
+ end
453
+ end
454
+
455
+ it "should enforce appear-once rule even with mass assigned header" do
456
+ header = Mail::Header.new(
457
+ "Content-Type: multipart/alternative\nContent-Type: text/plain\n"
458
+ )
459
+ header['content-type'].should_not be_kind_of(Array)
460
+ end
461
+
462
+ it "should add additional fields that can appear more than once" do
463
+ %w[ comments keywords x-spam].each do |field|
464
+ header = Mail::Header.new
465
+ header[field] = "1234"
466
+ header[field] = "5678"
467
+ header[field].map { |x| x.value }.should == ["1234", "5678"]
468
+ end
469
+ end
470
+
471
+ it "should delete all references to a field" do
472
+ header = Mail::Header.new
473
+ header.fields = ['X-Mail-SPAM: 15', 'X-Mail-SPAM: 20']
474
+ header['X-Mail-SPAM'] = '10000'
475
+ header['X-Mail-SPAM'].map { |x| x.value }.should == ['15', '20', '10000']
476
+ header['X-Mail-SPAM'] = nil
477
+ header['X-Mail-SPAM'].should == nil
478
+ end
479
+ end
480
+
481
+ describe "handling trace fields" do
482
+
483
+ before(:each) do
484
+ trace_header =<<TRACEHEADER
485
+ Return-Path: <xxx@xxxx.xxxtest>
486
+ Received: from xxx.xxxx.xxx by xxx.xxxx.xxx with ESMTP id 6AAEE3B4D23 for <xxx@xxxx.xxx>; Sun, 8 May 2005 12:30:23 -0500
487
+ Received: from xxx.xxxx.xxx by xxx.xxxx.xxx with ESMTP id j48HUC213279 for <xxx@xxxx.xxx>; Sun, 8 May 2005 12:30:13 -0500
488
+ Received: from conversion-xxx.xxxx.xxx.net by xxx.xxxx.xxx id <0IG600901LQ64I@xxx.xxxx.xxx> for <xxx@xxxx.xxx>; Sun, 8 May 2005 12:30:12 -0500
489
+ Received: from agw1 by xxx.xxxx.xxx with ESMTP id <0IG600JFYLYCAxxx@xxxx.xxx> for <xxx@xxxx.xxx>; Sun, 8 May 2005 12:30:12 -0500
490
+ TRACEHEADER
491
+ @traced_header = Mail::Header.new(trace_header)
492
+ end
493
+
494
+ it "should instantiate one trace field object per header" do
495
+ @traced_header.fields.length.should == 5
496
+ end
497
+
498
+ it "should add a new received header after the other received headers if they exist" do
499
+ @traced_header['To'] = "Mikel"
500
+ @traced_header['Received'] = "from agw2 by xxx.xxxx.xxx; Sun, 8 May 2005 12:30:13 -0500"
501
+ @traced_header.fields[0].addresses.should == ['xxx@xxxx.xxxtest']
502
+ @traced_header.fields[1].info.should == 'from xxx.xxxx.xxx by xxx.xxxx.xxx with ESMTP id 6AAEE3B4D23 for <xxx@xxxx.xxx>'
503
+ @traced_header.fields[2].info.should == 'from xxx.xxxx.xxx by xxx.xxxx.xxx with ESMTP id j48HUC213279 for <xxx@xxxx.xxx>'
504
+ @traced_header.fields[3].info.should == 'from conversion-xxx.xxxx.xxx.net by xxx.xxxx.xxx id <0IG600901LQ64I@xxx.xxxx.xxx> for <xxx@xxxx.xxx>'
505
+ @traced_header.fields[5].info.should == "from agw2 by xxx.xxxx.xxx"
506
+ @traced_header.fields[6].field.class.should == Mail::ToField
507
+ end
508
+
509
+ end
510
+
511
+ describe "encoding" do
512
+ it "should output a parsed version of itself to US-ASCII on encoded and tidy up and sort correctly" do
513
+ header = Mail::Header.new("To: Mikel\r\n\tLindsaar <mikel@test.lindsaar.net>\r\nFrom: bob\r\n\t<bob@test.lindsaar.net>\r\nSubject: This is\r\n a long\r\n\t \t \t \t badly formatted \r\n \t\t \t field")
514
+ result = "From: bob <bob@test.lindsaar.net>\r\nTo: Mikel Lindsaar <mikel@test.lindsaar.net>\r\nSubject: This is a long badly formatted field\r\n"
515
+ header.encoded.should == result
516
+ end
517
+ end
518
+
519
+ describe "detecting required fields" do
520
+ it "should not say it has a message id if it doesn't" do
521
+ Mail::Header.new.should_not be_has_message_id
522
+ end
523
+
524
+ it "should say it has a message id if it does" do
525
+ Mail::Header.new('Message-ID: 1234').should be_has_message_id
526
+ end
527
+
528
+ it "should not say it has a date if it doesn't" do
529
+ Mail::Header.new.should_not be_has_date
530
+ end
531
+
532
+ it "should say it has a date id if it does" do
533
+ Mail::Header.new('Date: Mon, 24 Nov 1997 14:22:01 -0800').should be_has_date
534
+ end
535
+
536
+ it "should not say it has a mime-version if it doesn't" do
537
+ Mail::Header.new.should_not be_has_mime_version
538
+ end
539
+
540
+ it "should say it has a date id if it does" do
541
+ Mail::Header.new('Mime-Version: 1.0').should be_has_mime_version
542
+ end
543
+ end
544
+
545
+ describe "mime version handling" do
546
+ it "should return the mime version of the email" do
547
+ header = Mail::Header.new("Mime-Version: 1.0")
548
+ header['mime-version'].value.should == '1.0'
549
+ end
550
+
551
+ it "should return nil if no mime-version header field" do
552
+ header = Mail::Header.new('To: bob')
553
+ header['mime_version'].should == nil
554
+ end
555
+
556
+ it "should return the transfer-encoding of the email" do
557
+ header = Mail::Header.new("Content-Transfer-Encoding: Base64")
558
+ header['content-transfer-encoding'].value.should == 'Base64'
559
+ end
560
+
561
+ it "should return nil if no transfer-encoding header field" do
562
+ header = Mail::Header.new
563
+ header['content-transfer-encoding'].should == nil
564
+ end
565
+
566
+ it "should return the content-description of the email" do
567
+ header = Mail::Header.new("Content-Description: This is a description")
568
+ header['Content-Description'].value.should == 'This is a description'
569
+ end
570
+
571
+ it "should return nil if no content-description header field" do
572
+ header = Mail::Header.new
573
+ header['Content-Description'].should == nil
574
+ end
575
+
576
+ end
577
+
578
+ end