rack-mail_exception 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +22 -0
- data/LICENSE +20 -0
- data/README.rdoc +38 -0
- data/Rakefile +56 -0
- data/VERSION +1 -0
- data/lib/rack/mail_exception.rb +103 -0
- data/test/helper.rb +13 -0
- data/test/test_rack_mail_exception.rb +93 -0
- data/vendor/mail/.bundle/config +2 -0
- data/vendor/mail/CHANGELOG.rdoc +370 -0
- data/vendor/mail/Dependencies.txt +3 -0
- data/vendor/mail/Gemfile +17 -0
- data/vendor/mail/README.rdoc +572 -0
- data/vendor/mail/ROADMAP +92 -0
- data/vendor/mail/Rakefile +41 -0
- data/vendor/mail/TODO.rdoc +9 -0
- data/vendor/mail/lib/mail.rb +76 -0
- data/vendor/mail/lib/mail/attachments_list.rb +99 -0
- data/vendor/mail/lib/mail/body.rb +287 -0
- data/vendor/mail/lib/mail/configuration.rb +67 -0
- data/vendor/mail/lib/mail/core_extensions/blank.rb +26 -0
- data/vendor/mail/lib/mail/core_extensions/nil.rb +11 -0
- data/vendor/mail/lib/mail/core_extensions/string.rb +27 -0
- data/vendor/mail/lib/mail/elements.rb +14 -0
- data/vendor/mail/lib/mail/elements/address.rb +306 -0
- data/vendor/mail/lib/mail/elements/address_list.rb +74 -0
- data/vendor/mail/lib/mail/elements/content_disposition_element.rb +30 -0
- data/vendor/mail/lib/mail/elements/content_location_element.rb +25 -0
- data/vendor/mail/lib/mail/elements/content_transfer_encoding_element.rb +24 -0
- data/vendor/mail/lib/mail/elements/content_type_element.rb +35 -0
- data/vendor/mail/lib/mail/elements/date_time_element.rb +26 -0
- data/vendor/mail/lib/mail/elements/envelope_from_element.rb +34 -0
- data/vendor/mail/lib/mail/elements/message_ids_element.rb +29 -0
- data/vendor/mail/lib/mail/elements/mime_version_element.rb +26 -0
- data/vendor/mail/lib/mail/elements/phrase_list.rb +21 -0
- data/vendor/mail/lib/mail/elements/received_element.rb +30 -0
- data/vendor/mail/lib/mail/encodings.rb +258 -0
- data/vendor/mail/lib/mail/encodings/7bit.rb +31 -0
- data/vendor/mail/lib/mail/encodings/8bit.rb +31 -0
- data/vendor/mail/lib/mail/encodings/base64.rb +33 -0
- data/vendor/mail/lib/mail/encodings/binary.rb +31 -0
- data/vendor/mail/lib/mail/encodings/quoted_printable.rb +38 -0
- data/vendor/mail/lib/mail/encodings/transfer_encoding.rb +58 -0
- data/vendor/mail/lib/mail/envelope.rb +35 -0
- data/vendor/mail/lib/mail/field.rb +223 -0
- data/vendor/mail/lib/mail/field_list.rb +33 -0
- data/vendor/mail/lib/mail/fields.rb +35 -0
- data/vendor/mail/lib/mail/fields/bcc_field.rb +56 -0
- data/vendor/mail/lib/mail/fields/cc_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/comments_field.rb +41 -0
- data/vendor/mail/lib/mail/fields/common/address_container.rb +16 -0
- data/vendor/mail/lib/mail/fields/common/common_address.rb +125 -0
- data/vendor/mail/lib/mail/fields/common/common_date.rb +42 -0
- data/vendor/mail/lib/mail/fields/common/common_field.rb +50 -0
- data/vendor/mail/lib/mail/fields/common/common_message_id.rb +43 -0
- data/vendor/mail/lib/mail/fields/common/parameter_hash.rb +52 -0
- data/vendor/mail/lib/mail/fields/content_description_field.rb +19 -0
- data/vendor/mail/lib/mail/fields/content_disposition_field.rb +69 -0
- data/vendor/mail/lib/mail/fields/content_id_field.rb +63 -0
- data/vendor/mail/lib/mail/fields/content_location_field.rb +42 -0
- data/vendor/mail/lib/mail/fields/content_transfer_encoding_field.rb +50 -0
- data/vendor/mail/lib/mail/fields/content_type_field.rb +185 -0
- data/vendor/mail/lib/mail/fields/date_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/from_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/in_reply_to_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/keywords_field.rb +44 -0
- data/vendor/mail/lib/mail/fields/message_id_field.rb +83 -0
- data/vendor/mail/lib/mail/fields/mime_version_field.rb +53 -0
- data/vendor/mail/lib/mail/fields/optional_field.rb +13 -0
- data/vendor/mail/lib/mail/fields/received_field.rb +67 -0
- data/vendor/mail/lib/mail/fields/references_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/reply_to_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/resent_bcc_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/resent_cc_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/resent_date_field.rb +35 -0
- data/vendor/mail/lib/mail/fields/resent_from_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/resent_message_id_field.rb +34 -0
- data/vendor/mail/lib/mail/fields/resent_sender_field.rb +62 -0
- data/vendor/mail/lib/mail/fields/resent_to_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/return_path_field.rb +64 -0
- data/vendor/mail/lib/mail/fields/sender_field.rb +67 -0
- data/vendor/mail/lib/mail/fields/structured_field.rb +51 -0
- data/vendor/mail/lib/mail/fields/subject_field.rb +16 -0
- data/vendor/mail/lib/mail/fields/to_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/unstructured_field.rb +166 -0
- data/vendor/mail/lib/mail/header.rb +262 -0
- data/vendor/mail/lib/mail/mail.rb +234 -0
- data/vendor/mail/lib/mail/message.rb +1867 -0
- data/vendor/mail/lib/mail/network.rb +9 -0
- data/vendor/mail/lib/mail/network/delivery_methods/file_delivery.rb +40 -0
- data/vendor/mail/lib/mail/network/delivery_methods/sendmail.rb +62 -0
- data/vendor/mail/lib/mail/network/delivery_methods/smtp.rb +110 -0
- data/vendor/mail/lib/mail/network/delivery_methods/test_mailer.rb +40 -0
- data/vendor/mail/lib/mail/network/retriever_methods/imap.rb +18 -0
- data/vendor/mail/lib/mail/network/retriever_methods/pop3.rb +149 -0
- data/vendor/mail/lib/mail/parsers/address_lists.rb +64 -0
- data/vendor/mail/lib/mail/parsers/address_lists.treetop +19 -0
- data/vendor/mail/lib/mail/parsers/content_disposition.rb +387 -0
- data/vendor/mail/lib/mail/parsers/content_disposition.treetop +46 -0
- data/vendor/mail/lib/mail/parsers/content_location.rb +139 -0
- data/vendor/mail/lib/mail/parsers/content_location.treetop +20 -0
- data/vendor/mail/lib/mail/parsers/content_transfer_encoding.rb +162 -0
- data/vendor/mail/lib/mail/parsers/content_transfer_encoding.treetop +20 -0
- data/vendor/mail/lib/mail/parsers/content_type.rb +539 -0
- data/vendor/mail/lib/mail/parsers/content_type.treetop +58 -0
- data/vendor/mail/lib/mail/parsers/date_time.rb +114 -0
- data/vendor/mail/lib/mail/parsers/date_time.treetop +11 -0
- data/vendor/mail/lib/mail/parsers/envelope_from.rb +194 -0
- data/vendor/mail/lib/mail/parsers/envelope_from.treetop +32 -0
- data/vendor/mail/lib/mail/parsers/message_ids.rb +45 -0
- data/vendor/mail/lib/mail/parsers/message_ids.treetop +15 -0
- data/vendor/mail/lib/mail/parsers/mime_version.rb +144 -0
- data/vendor/mail/lib/mail/parsers/mime_version.treetop +19 -0
- data/vendor/mail/lib/mail/parsers/phrase_lists.rb +45 -0
- data/vendor/mail/lib/mail/parsers/phrase_lists.treetop +15 -0
- data/vendor/mail/lib/mail/parsers/received.rb +71 -0
- data/vendor/mail/lib/mail/parsers/received.treetop +11 -0
- data/vendor/mail/lib/mail/parsers/rfc2045.rb +464 -0
- data/vendor/mail/lib/mail/parsers/rfc2045.treetop +36 -0
- data/vendor/mail/lib/mail/parsers/rfc2822.rb +5318 -0
- data/vendor/mail/lib/mail/parsers/rfc2822.treetop +410 -0
- data/vendor/mail/lib/mail/parsers/rfc2822_obsolete.rb +3757 -0
- data/vendor/mail/lib/mail/parsers/rfc2822_obsolete.treetop +241 -0
- data/vendor/mail/lib/mail/part.rb +102 -0
- data/vendor/mail/lib/mail/parts_list.rb +34 -0
- data/vendor/mail/lib/mail/patterns.rb +30 -0
- data/vendor/mail/lib/mail/utilities.rb +181 -0
- data/vendor/mail/lib/mail/version.rb +10 -0
- data/vendor/mail/lib/mail/version_specific/ruby_1_8.rb +97 -0
- data/vendor/mail/lib/mail/version_specific/ruby_1_9.rb +87 -0
- data/vendor/mail/lib/tasks/corpus.rake +125 -0
- data/vendor/mail/lib/tasks/treetop.rake +10 -0
- data/vendor/mail/mail.gemspec +20 -0
- data/vendor/mail/reference/US ASCII Table.txt +130 -0
- data/vendor/mail/reference/rfc1035 Domain Implementation and Specification.txt +3083 -0
- data/vendor/mail/reference/rfc1049 Content-Type Header Field for Internet Messages.txt +451 -0
- data/vendor/mail/reference/rfc1344 Implications of MIME for Internet Mail Gateways.txt +586 -0
- data/vendor/mail/reference/rfc1345 Character Mnemonics & Character Sets.txt +5761 -0
- data/vendor/mail/reference/rfc1524 A User Agent Configuration Mechanism For Multimedia Mail Format Information.txt +675 -0
- data/vendor/mail/reference/rfc1652 SMTP Service Extension for 8bit-MIMEtransport.txt +339 -0
- data/vendor/mail/reference/rfc1892 Multipart Report .txt +227 -0
- data/vendor/mail/reference/rfc1893 Mail System Status Codes.txt +843 -0
- data/vendor/mail/reference/rfc2045 Multipurpose Internet Mail Extensions (1).txt +1739 -0
- data/vendor/mail/reference/rfc2046 Multipurpose Internet Mail Extensions (2).txt +2467 -0
- data/vendor/mail/reference/rfc2047 Multipurpose Internet Mail Extensions (3).txt +843 -0
- data/vendor/mail/reference/rfc2048 Multipurpose Internet Mail Extensions (4).txt +1180 -0
- data/vendor/mail/reference/rfc2049 Multipurpose Internet Mail Extensions (5).txt +1347 -0
- data/vendor/mail/reference/rfc2111 Content-ID and Message-ID URLs.txt +283 -0
- data/vendor/mail/reference/rfc2183 Content-Disposition Header Field.txt +675 -0
- data/vendor/mail/reference/rfc2231 MIME Parameter Value and Encoded Word Extensions.txt +563 -0
- data/vendor/mail/reference/rfc2387 MIME Multipart-Related Content-type.txt +563 -0
- data/vendor/mail/reference/rfc2821 Simple Mail Transfer Protocol.txt +3711 -0
- data/vendor/mail/reference/rfc2822 Internet Message Format.txt +2859 -0
- data/vendor/mail/reference/rfc3462 Reporting of Mail System Administrative Messages.txt +396 -0
- data/vendor/mail/reference/rfc3696 Checking and Transformation of Names.txt +898 -0
- data/vendor/mail/reference/rfc4155 The application-mbox Media Type.txt +502 -0
- data/vendor/mail/reference/rfc4234 Augmented BNF for Syntax Specifications: ABNF.txt +899 -0
- data/vendor/mail/reference/rfc822 Standard for the Format of ARPA Internet Text Messages.txt +2900 -0
- data/vendor/mail/spec/environment.rb +15 -0
- data/vendor/mail/spec/features/making_a_new_message.feature +14 -0
- data/vendor/mail/spec/features/steps/env.rb +6 -0
- data/vendor/mail/spec/features/steps/making_a_new_message_steps.rb +11 -0
- data/vendor/mail/spec/fixtures/attachments/basic_email.eml +31 -0
- data/vendor/mail/spec/fixtures/attachments/test.gif +0 -0
- data/vendor/mail/spec/fixtures/attachments/test.jpg +0 -0
- data/vendor/mail/spec/fixtures/attachments/test.pdf +0 -0
- data/vendor/mail/spec/fixtures/attachments/test.png +0 -0
- data/vendor/mail/spec/fixtures/attachments/test.tiff +0 -0
- data/vendor/mail/spec/fixtures/attachments/test.zip +0 -0
- data/vendor/mail/spec/fixtures/attachments//343/201/246/343/201/231/343/201/250.txt +2 -0
- data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_content_disposition.eml +29 -0
- data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_content_location.eml +32 -0
- data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_message_rfc822.eml +92 -0
- data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_only_email.eml +17 -0
- data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_pdf.eml +70 -0
- data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_with_encoded_name.eml +47 -0
- data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_with_quoted_filename.eml +60 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/cant_parse_from.eml +33 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_7-bit.eml +231 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_empty.eml +33 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_plain.eml +148 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_qp_with_space.eml +53 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_spam.eml +44 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_text-html.eml +50 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_with_8bits.eml +770 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_with_semi_colon.eml +269 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_x_uuencode.eml +79 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/empty_group_lists.eml +162 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/header_fields_with_empty_values.eml +33 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/missing_body.eml +16 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/missing_content_disposition.eml +43 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/multiple_content_types.eml +25 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email11.eml +34 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email12.eml +32 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email2.eml +114 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email4.eml +59 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email7.eml +66 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_encoded_stack_level_too_deep.eml +53 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_illegal_boundary.eml +58 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_mimepart_without_content_type.eml +94 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_multipart_mixed_quoted_boundary.eml +50 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_nested_attachment.eml +100 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_quoted_illegal_boundary.eml +58 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/sig_only_email.eml +29 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/two_from_in_message.eml +42 -0
- data/vendor/mail/spec/fixtures/emails/multi_charset/japanese.eml +9 -0
- data/vendor/mail/spec/fixtures/emails/multi_charset/japanese_attachment.eml +27 -0
- data/vendor/mail/spec/fixtures/emails/multi_charset/japanese_attachment_long_name.eml +44 -0
- data/vendor/mail/spec/fixtures/emails/multipart_report_emails/multi_address_bounce1.eml +179 -0
- data/vendor/mail/spec/fixtures/emails/multipart_report_emails/multi_address_bounce2.eml +179 -0
- data/vendor/mail/spec/fixtures/emails/multipart_report_emails/report_422.eml +98 -0
- data/vendor/mail/spec/fixtures/emails/multipart_report_emails/report_530.eml +97 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/basic_email.eml +31 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email.eml +14 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email10.eml +20 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email5.eml +19 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email6.eml +20 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email8.eml +47 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_bad_time.eml +62 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_double_at_in_header.eml +14 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_incorrect_header.eml +28 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_multiple_from.eml +30 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_quoted_with_0d0a.eml +14 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_reply.eml +32 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_simple.eml +11 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_string_in_date_field.eml +17 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_trailing_dot.eml +21 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_with_bad_date.eml +48 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_with_partially_quoted_subject.eml +14 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example01.eml +8 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example02.eml +9 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example03.eml +7 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example04.eml +7 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example05.eml +8 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example06.eml +10 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example07.eml +9 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example08.eml +12 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example09.eml +15 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example10.eml +15 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example11.eml +6 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example12.eml +8 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example13.eml +10 -0
- data/vendor/mail/spec/fixtures/emails/sample_output_multipart +0 -0
- data/vendor/mail/spec/mail/attachments_list_spec.rb +214 -0
- data/vendor/mail/spec/mail/body_spec.rb +385 -0
- data/vendor/mail/spec/mail/configuration_spec.rb +19 -0
- data/vendor/mail/spec/mail/core_extensions/string_spec.rb +62 -0
- data/vendor/mail/spec/mail/core_extensions_spec.rb +99 -0
- data/vendor/mail/spec/mail/elements/address_list_spec.rb +109 -0
- data/vendor/mail/spec/mail/elements/address_spec.rb +609 -0
- data/vendor/mail/spec/mail/elements/date_time_element_spec.rb +20 -0
- data/vendor/mail/spec/mail/elements/envelope_from_element_spec.rb +31 -0
- data/vendor/mail/spec/mail/elements/message_ids_element_spec.rb +43 -0
- data/vendor/mail/spec/mail/elements/phrase_list_spec.rb +22 -0
- data/vendor/mail/spec/mail/elements/received_element_spec.rb +34 -0
- data/vendor/mail/spec/mail/encoding_spec.rb +189 -0
- data/vendor/mail/spec/mail/encodings/base64_spec.rb +25 -0
- data/vendor/mail/spec/mail/encodings/quoted_printable_spec.rb +25 -0
- data/vendor/mail/spec/mail/encodings_spec.rb +664 -0
- data/vendor/mail/spec/mail/example_emails_spec.rb +303 -0
- data/vendor/mail/spec/mail/field_list_spec.rb +33 -0
- data/vendor/mail/spec/mail/field_spec.rb +198 -0
- data/vendor/mail/spec/mail/fields/bcc_field_spec.rb +89 -0
- data/vendor/mail/spec/mail/fields/cc_field_spec.rb +79 -0
- data/vendor/mail/spec/mail/fields/comments_field_spec.rb +25 -0
- data/vendor/mail/spec/mail/fields/common/address_container_spec.rb +18 -0
- data/vendor/mail/spec/mail/fields/common/common_address_spec.rb +132 -0
- data/vendor/mail/spec/mail/fields/common/common_date_spec.rb +25 -0
- data/vendor/mail/spec/mail/fields/common/common_field_spec.rb +69 -0
- data/vendor/mail/spec/mail/fields/common/common_message_id_spec.rb +30 -0
- data/vendor/mail/spec/mail/fields/common/parameter_hash_spec.rb +56 -0
- data/vendor/mail/spec/mail/fields/content_description_field_spec.rb +39 -0
- data/vendor/mail/spec/mail/fields/content_disposition_field_spec.rb +55 -0
- data/vendor/mail/spec/mail/fields/content_id_field_spec.rb +117 -0
- data/vendor/mail/spec/mail/fields/content_location_field_spec.rb +46 -0
- data/vendor/mail/spec/mail/fields/content_transfer_encoding_field_spec.rb +113 -0
- data/vendor/mail/spec/mail/fields/content_type_field_spec.rb +678 -0
- data/vendor/mail/spec/mail/fields/date_field_spec.rb +73 -0
- data/vendor/mail/spec/mail/fields/envelope_spec.rb +48 -0
- data/vendor/mail/spec/mail/fields/from_field_spec.rb +89 -0
- data/vendor/mail/spec/mail/fields/in_reply_to_field_spec.rb +62 -0
- data/vendor/mail/spec/mail/fields/keywords_field_spec.rb +66 -0
- data/vendor/mail/spec/mail/fields/message_id_field_spec.rb +147 -0
- data/vendor/mail/spec/mail/fields/mime_version_field_spec.rb +166 -0
- data/vendor/mail/spec/mail/fields/received_field_spec.rb +44 -0
- data/vendor/mail/spec/mail/fields/references_field_spec.rb +35 -0
- data/vendor/mail/spec/mail/fields/reply_to_field_spec.rb +67 -0
- data/vendor/mail/spec/mail/fields/resent_bcc_field_spec.rb +66 -0
- data/vendor/mail/spec/mail/fields/resent_cc_field_spec.rb +66 -0
- data/vendor/mail/spec/mail/fields/resent_date_field_spec.rb +39 -0
- data/vendor/mail/spec/mail/fields/resent_from_field_spec.rb +66 -0
- data/vendor/mail/spec/mail/fields/resent_message_id_field_spec.rb +24 -0
- data/vendor/mail/spec/mail/fields/resent_sender_field_spec.rb +58 -0
- data/vendor/mail/spec/mail/fields/resent_to_field_spec.rb +66 -0
- data/vendor/mail/spec/mail/fields/return_path_field_spec.rb +52 -0
- data/vendor/mail/spec/mail/fields/sender_field_spec.rb +58 -0
- data/vendor/mail/spec/mail/fields/structured_field_spec.rb +72 -0
- data/vendor/mail/spec/mail/fields/to_field_spec.rb +92 -0
- data/vendor/mail/spec/mail/fields/unstructured_field_spec.rb +134 -0
- data/vendor/mail/spec/mail/header_spec.rb +578 -0
- data/vendor/mail/spec/mail/mail_spec.rb +34 -0
- data/vendor/mail/spec/mail/message_spec.rb +1409 -0
- data/vendor/mail/spec/mail/mime_messages_spec.rb +435 -0
- data/vendor/mail/spec/mail/multipart_report_spec.rb +112 -0
- data/vendor/mail/spec/mail/network/delivery_methods/file_delivery_spec.rb +79 -0
- data/vendor/mail/spec/mail/network/delivery_methods/sendmail_spec.rb +125 -0
- data/vendor/mail/spec/mail/network/delivery_methods/smtp_spec.rb +133 -0
- data/vendor/mail/spec/mail/network/delivery_methods/test_mailer_spec.rb +57 -0
- data/vendor/mail/spec/mail/network/retriever_methods/pop3_spec.rb +180 -0
- data/vendor/mail/spec/mail/network_spec.rb +359 -0
- data/vendor/mail/spec/mail/parsers/address_lists_parser_spec.rb +15 -0
- data/vendor/mail/spec/mail/parsers/content_transfer_encoding_parser_spec.rb +72 -0
- data/vendor/mail/spec/mail/part_spec.rb +129 -0
- data/vendor/mail/spec/mail/parts_list_spec.rb +12 -0
- data/vendor/mail/spec/mail/round_tripping_spec.rb +44 -0
- data/vendor/mail/spec/mail/utilities_spec.rb +327 -0
- data/vendor/mail/spec/mail/version_specific/escape_paren_1_8_spec.rb +32 -0
- data/vendor/mail/spec/matchers/break_down_to.rb +35 -0
- data/vendor/mail/spec/spec_helper.rb +163 -0
- metadata +442 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mail::DateTimeElement do
|
4
|
+
|
5
|
+
it "should parse a date" do
|
6
|
+
date_text = 'Wed, 27 Apr 2005 14:15:31 -0700'
|
7
|
+
doing { Mail::DateTimeElement.new(date_text) }.should_not raise_error
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should raise an error if the input is useless" do
|
11
|
+
date_text = nil
|
12
|
+
doing { Mail::DateTimeElement.new(date_text) }.should raise_error
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should raise an error if the input is useless" do
|
16
|
+
date_text = '""""""""""""""""'
|
17
|
+
doing { Mail::DateTimeElement.new(date_text) }.should raise_error
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mail::EnvelopeFromElement do
|
4
|
+
|
5
|
+
describe "parsing a from envelope string" do
|
6
|
+
it "should parse a full field" do
|
7
|
+
Mail::EnvelopeFromElement.new("mikel@test.lindsaar.net Mon Aug 7 00:39:21 2009").tree.should_not be_nil
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should parse a full field with a double digit day" do
|
11
|
+
Mail::EnvelopeFromElement.new("mikel@test.lindsaar.net Mon Aug 17 00:39:21 2009").tree.should_not be_nil
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should parse a full field with a single space day" do
|
15
|
+
Mail::EnvelopeFromElement.new("mikel@test.lindsaar.net Mon Aug 17 00:39:21 2009").tree.should_not be_nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "accessor methods" do
|
20
|
+
it "should return the address" do
|
21
|
+
envelope = Mail::EnvelopeFromElement.new("mikel@test.lindsaar.net Mon Aug 17 00:39:21 2009")
|
22
|
+
envelope.address.should == "mikel@test.lindsaar.net"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should return the date_time" do
|
26
|
+
envelope = Mail::EnvelopeFromElement.new("mikel@test.lindsaar.net Mon Aug 17 00:39:21 2009")
|
27
|
+
envelope.date_time.should == ::DateTime.parse("Mon Aug 17 00:39:21 2009")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mail::MessageIdsElement do
|
4
|
+
|
5
|
+
it "should parse a message_id" do
|
6
|
+
msg_id_text = '<1234@test.lindsaar.net>'
|
7
|
+
doing { Mail::MessageIdsElement.new(msg_id_text) }.should_not raise_error
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should parse multiple message_ids" do
|
11
|
+
msg_id_text = '<1234@test.lindsaar.net> <1234@test.lindsaar.net>'
|
12
|
+
doing { Mail::MessageIdsElement.new(msg_id_text) }.should_not raise_error
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should raise an error if the input is useless" do
|
16
|
+
msg_id_text = nil
|
17
|
+
doing { Mail::MessageIdsElement.new(msg_id_text) }.should raise_error
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should raise an error if the input is useless" do
|
21
|
+
msg_id_text = '""""""""""""""""'
|
22
|
+
doing { Mail::MessageIdsElement.new(msg_id_text) }.should raise_error
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should respond to message_ids" do
|
26
|
+
msg_id_text = '<1234@test.lindsaar.net> <1234@test.lindsaar.net>'
|
27
|
+
msg_ids = Mail::MessageIdsElement.new(msg_id_text)
|
28
|
+
msg_ids.message_ids.should == ['1234@test.lindsaar.net', '1234@test.lindsaar.net']
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should respond to message_id" do
|
32
|
+
msg_id_text = '<1234@test.lindsaar.net>'
|
33
|
+
msg_ids = Mail::MessageIdsElement.new(msg_id_text)
|
34
|
+
msg_ids.message_id.should == '1234@test.lindsaar.net'
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should not fail to parse a message id with dots in it" do
|
38
|
+
text = "<4afb664ca3078_48dc..fdbe32b865532b@ax-desktop.mail>"
|
39
|
+
m = Mail::MessageIdsElement.new(text)
|
40
|
+
m.message_id.should == "4afb664ca3078_48dc..fdbe32b865532b@ax-desktop.mail"
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Mail::PhraseList do
|
5
|
+
|
6
|
+
describe "parsing" do
|
7
|
+
it "should parse a phrase list" do
|
8
|
+
parse_text = '"Mikel Lindsaar", "Mikel", you, somewhere'
|
9
|
+
doing { Mail::PhraseList.new(parse_text) }.should_not raise_error
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should raise an error if the input is useless" do
|
13
|
+
parse_text = nil
|
14
|
+
doing { Mail::PhraseList.new(parse_text) }.should raise_error
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should raise an error if the input is useless" do
|
18
|
+
parse_text = '""""""""""""""""'
|
19
|
+
doing { Mail::PhraseList.new(parse_text) }.should raise_error
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mail::ReceivedElement do
|
4
|
+
|
5
|
+
it "should parse a date" do
|
6
|
+
received_text = 'from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <xxxx@xxxx.com>; Tue, 10 May 2005 17:26:50 +0000 (GMT)'
|
7
|
+
doing { Mail::ReceivedElement.new(received_text) }.should_not raise_error
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should raise an error if the input is useless" do
|
11
|
+
received_text = nil
|
12
|
+
doing { Mail::ReceivedElement.new(received_text) }.should raise_error
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should raise an error if the input is useless" do
|
16
|
+
received_text = '""""""""""""""""'
|
17
|
+
doing { Mail::ReceivedElement.new(received_text) }.should raise_error
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should give back the date time" do
|
21
|
+
received_text = 'from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <xxxx@xxxx.com>; Tue, 10 May 2005 17:26:50 +0000 (GMT)'
|
22
|
+
date_text = '10 May 2005 17:26:50 +0000 (GMT)'
|
23
|
+
rec = Mail::ReceivedElement.new(received_text)
|
24
|
+
rec.date_time.should == ::DateTime.parse(date_text)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should give back the info" do
|
28
|
+
received_text = 'from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <xxxx@xxxx.com>; Tue, 10 May 2005 17:26:50 +0000 (GMT)'
|
29
|
+
info_text = 'from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <xxxx@xxxx.com>'
|
30
|
+
rec = Mail::ReceivedElement.new(received_text)
|
31
|
+
rec.info.should == info_text
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,189 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.join(File.dirname(File.expand_path(__FILE__)), '..', 'spec_helper')
|
3
|
+
|
4
|
+
describe "mail encoding" do
|
5
|
+
|
6
|
+
it "should allow you to assign a mail wide charset" do
|
7
|
+
mail = Mail.new
|
8
|
+
mail.charset = 'utf-8'
|
9
|
+
mail.charset.should == 'utf-8'
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "using default encoding" do
|
13
|
+
it "should allow you to send in unencoded strings to fields and encode them" do
|
14
|
+
mail = Mail.new
|
15
|
+
mail.charset = 'utf-8'
|
16
|
+
mail.subject = "This is あ string"
|
17
|
+
result = "Subject: This =?UTF8?Q?is_=E3=81=82=?= string\r\n"
|
18
|
+
mail[:subject].encoded.gsub("UTF-8", "UTF8").should == result
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should allow you to send in unencoded strings to address fields and encode them" do
|
22
|
+
mail = Mail.new
|
23
|
+
mail.charset = 'utf-8'
|
24
|
+
mail.to = "Mikel Lindsああr <mikel@test.lindsaar.net>"
|
25
|
+
result = "To: Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <mikel@test.lindsaar.net>\r\n"
|
26
|
+
mail[:to].encoded.should == result
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should allow you to send in unencoded strings to address fields and encode them" do
|
30
|
+
mail = Mail.new
|
31
|
+
mail.charset = 'utf-8'
|
32
|
+
mail.to = "あdあ <ada@test.lindsaar.net>"
|
33
|
+
result = "To: =?UTF-8?B?44GCZOOBgg==?= <ada@test.lindsaar.net>\r\n"
|
34
|
+
mail[:to].encoded.should == result
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should allow you to send in multiple unencoded strings to address fields and encode them" do
|
38
|
+
mail = Mail.new
|
39
|
+
mail.charset = 'utf-8'
|
40
|
+
mail.to = ["Mikel Lindsああr <mikel@test.lindsaar.net>", "あdあ <ada@test.lindsaar.net>"]
|
41
|
+
result = "To: Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <mikel@test.lindsaar.net>, \r\n\t=?UTF-8?B?44GCZOOBgg==?= <ada@test.lindsaar.net>\r\n"
|
42
|
+
mail[:to].encoded.should == result
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should allow you to send unquoted non us-ascii strings, with spaces in them" do
|
46
|
+
mail = Mail.new
|
47
|
+
mail.charset = 'utf-8'
|
48
|
+
mail.to = ["Foo áëô îü <extended@example.net>"]
|
49
|
+
result = "To: Foo =?UTF-8?B?w6HDq8O0?= =?UTF-8?B?IMOuw7w=?= <extended@example.net>\r\n"
|
50
|
+
mail[:to].encoded.should == result
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should allow you to send in multiple unencoded strings to any address field" do
|
54
|
+
mail = Mail.new
|
55
|
+
mail.charset = 'utf-8'
|
56
|
+
['To', 'From', 'Cc', 'Reply-To'].each do |field|
|
57
|
+
mail.send("#{field.downcase.gsub("-", '_')}=", ["Mikel Lindsああr <mikel@test.lindsaar.net>", "あdあ <ada@test.lindsaar.net>"])
|
58
|
+
result = "#{field}: Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <mikel@test.lindsaar.net>, \r\n\t=?UTF-8?B?44GCZOOBgg==?= <ada@test.lindsaar.net>\r\n"
|
59
|
+
mail[field].encoded.should == result
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should handle groups" do
|
64
|
+
mail = Mail.new
|
65
|
+
mail.charset = 'utf-8'
|
66
|
+
mail.to = "test1@lindsaar.net, group: test2@lindsaar.net, me@lindsaar.net;"
|
67
|
+
result = "To: test1@lindsaar.net, \r\n\tgroup: test2@lindsaar.net, \r\n\tme@lindsaar.net;\r\n"
|
68
|
+
mail[:to].encoded.should == result
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should handle groups with funky characters" do
|
72
|
+
mail = Mail.new
|
73
|
+
mail.charset = 'utf-8'
|
74
|
+
mail.to = '"Mikel Lindsああr" <test1@lindsaar.net>, group: "あdあ" <test2@lindsaar.net>, me@lindsaar.net;'
|
75
|
+
result = "To: =?UTF-8?B?TWlrZWwgTGluZHPjgYLjgYJy?= <test1@lindsaar.net>, \r\n\tgroup: =?UTF-8?B?44GCZOOBgg==?= <test2@lindsaar.net>, \r\n\tme@lindsaar.net;\r\n"
|
76
|
+
mail[:to].encoded.should == result
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "quouting token safe chars" do
|
80
|
+
|
81
|
+
it "should not quote the display name if unquoted" do
|
82
|
+
mail = Mail.new
|
83
|
+
mail.charset = 'utf-8'
|
84
|
+
mail.to = 'Mikel Lindsaar <mikel@test.lindsaar.net>'
|
85
|
+
mail[:to].encoded.should == %{To: Mikel Lindsaar <mikel@test.lindsaar.net>\r\n}
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should not quote the display name if already quoted" do
|
89
|
+
mail = Mail.new
|
90
|
+
mail.charset = 'utf-8'
|
91
|
+
mail.to = '"Mikel Lindsaar" <mikel@test.lindsaar.net>'
|
92
|
+
mail[:to].encoded.should == %{To: Mikel Lindsaar <mikel@test.lindsaar.net>\r\n}
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
describe "quoting token unsafe chars" do
|
98
|
+
it "should quote the display name" do
|
99
|
+
pending
|
100
|
+
mail = Mail.new
|
101
|
+
mail.charset = 'utf-8'
|
102
|
+
mail.to = "Mikel @ me Lindsaar <mikel@test.lindsaar.net>"
|
103
|
+
mail[:to].encoded.should == %{To: "Mikel @ me Lindsaar" <mikel@test.lindsaar.net>\r\n}
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should preserve quotes needed from the user and not double quote" do
|
107
|
+
mail = Mail.new
|
108
|
+
mail.charset = 'utf-8'
|
109
|
+
mail.to = %{"Mikel @ me Lindsaar" <mikel@test.lindsaar.net>}
|
110
|
+
mail[:to].encoded.should == %{To: "Mikel @ me Lindsaar" <mikel@test.lindsaar.net>\r\n}
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "specifying an email wide encoding" do
|
116
|
+
it "should allow you to send in unencoded strings to fields and encode them" do
|
117
|
+
mail = Mail.new
|
118
|
+
mail.charset = 'ISO-8859-1'
|
119
|
+
subject = "This is あ string"
|
120
|
+
subject.force_encoding('ISO8859-1') if RUBY_VERSION > '1.9'
|
121
|
+
mail.subject = subject
|
122
|
+
result = mail[:subject].encoded
|
123
|
+
string = "Subject: This =?ISO-8859-1?Q?is_=E3=81=82=?= string\r\n"
|
124
|
+
if RUBY_VERSION > '1.9'
|
125
|
+
string.force_encoding('ISO8859-1')
|
126
|
+
result.force_encoding('ISO8859-1')
|
127
|
+
end
|
128
|
+
result.should == string
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should allow you to send in unencoded strings to address fields and encode them" do
|
132
|
+
mail = Mail.new
|
133
|
+
mail.charset = 'ISO-8859-1'
|
134
|
+
string = "Mikel Lindsああr <mikel@test.lindsaar.net>"
|
135
|
+
string.force_encoding('ISO8859-1') if RUBY_VERSION > '1.9'
|
136
|
+
mail.to = string
|
137
|
+
result = mail[:to].encoded
|
138
|
+
string = "To: Mikel =?ISO-8859-1?B?TGluZHPjgYLjgYJy?= <mikel@test.lindsaar.net>\r\n"
|
139
|
+
if RUBY_VERSION > '1.9'
|
140
|
+
string.force_encoding('ISO8859-1')
|
141
|
+
result.force_encoding('ISO8859-1')
|
142
|
+
end
|
143
|
+
result.should == string
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should allow you to send in multiple unencoded strings to address fields and encode them" do
|
147
|
+
mail = Mail.new
|
148
|
+
mail.charset = 'ISO-8859-1'
|
149
|
+
array = ["Mikel Lindsああr <mikel@test.lindsaar.net>", "あdあ <ada@test.lindsaar.net>"]
|
150
|
+
array.map! { |a| a.force_encoding('ISO8859-1') } if RUBY_VERSION > '1.9'
|
151
|
+
mail.to = array
|
152
|
+
result = mail[:to].encoded
|
153
|
+
string = "To: Mikel =?ISO-8859-1?B?TGluZHPjgYLjgYJy?= <mikel@test.lindsaar.net>, \r\n\t=?ISO-8859-1?B?44GCZOOBgg==?= <ada@test.lindsaar.net>\r\n"
|
154
|
+
if RUBY_VERSION > '1.9'
|
155
|
+
string.force_encoding('ISO8859-1')
|
156
|
+
result.force_encoding('ISO8859-1')
|
157
|
+
end
|
158
|
+
result.should == string
|
159
|
+
end
|
160
|
+
|
161
|
+
it "should allow you to send in multiple unencoded strings to any address field" do
|
162
|
+
mail = Mail.new
|
163
|
+
array = ["Mikel Lindsああr <mikel@test.lindsaar.net>", "あdあ <ada@test.lindsaar.net>"]
|
164
|
+
array.map! { |a| a.force_encoding('ISO8859-1') } if RUBY_VERSION > '1.9'
|
165
|
+
mail.charset = 'ISO-8859-1'
|
166
|
+
['To', 'From', 'Cc', 'Reply-To'].each do |field|
|
167
|
+
mail.send("#{field.downcase.gsub("-", '_')}=", array)
|
168
|
+
string = "#{field}: Mikel =?ISO-8859-1?B?TGluZHPjgYLjgYJy?= <mikel@test.lindsaar.net>, \r\n\t=?ISO-8859-1?B?44GCZOOBgg==?= <ada@test.lindsaar.net>\r\n"
|
169
|
+
result = mail[field].encoded
|
170
|
+
if RUBY_VERSION > '1.9'
|
171
|
+
string.force_encoding('ISO8859-1')
|
172
|
+
result.force_encoding('ISO8859-1')
|
173
|
+
end
|
174
|
+
result.should == string
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
it "should let you define a charset per part" do
|
180
|
+
mail = Mail.new
|
181
|
+
part = Mail::Part.new
|
182
|
+
part.content_type = "text/html"
|
183
|
+
part.charset = "ISO-8859-1"
|
184
|
+
part.body = "blah"
|
185
|
+
mail.add_part(part)
|
186
|
+
mail.parts[0].content_type.should == "text/html; charset=ISO-8859-1"
|
187
|
+
end
|
188
|
+
|
189
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mail::Encodings::Base64 do
|
4
|
+
|
5
|
+
it "should encode base 64 from text" do
|
6
|
+
result = "VGhpcyBpcyBhIHRlc3Q=\r\n"
|
7
|
+
Mail::Encodings::Base64.encode('This is a test').should == result
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should decode base 64 text" do
|
11
|
+
result = 'This is a test'
|
12
|
+
Mail::Encodings::Base64.decode("VGhpcyBpcyBhIHRlc3Q=\n").should == result
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should encode base 64 from binary" do
|
16
|
+
result = "AAAAAA==\r\n"
|
17
|
+
Mail::Encodings::Base64.encode("\000\000\000\000").should == result
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should decode base 64 text" do
|
21
|
+
result = "\000\000\000\000"
|
22
|
+
Mail::Encodings::Base64.decode("AAAAAA==\n").should == result
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mail::Encodings::QuotedPrintable do
|
4
|
+
|
5
|
+
it "should encode quoted printable from text" do
|
6
|
+
result = "This is a test=\r\n"
|
7
|
+
Mail::Encodings::QuotedPrintable.encode('This is a test').should == result
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should decode quoted printable" do
|
11
|
+
result = "This is a test"
|
12
|
+
Mail::Encodings::QuotedPrintable.decode("This is a test").should == result
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should encode quoted printable from binary" do
|
16
|
+
result = "=00=00=00=00=\r\n"
|
17
|
+
Mail::Encodings::QuotedPrintable.encode("\000\000\000\000").should == result
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should decode quoted printable text" do
|
21
|
+
result = "\000\000\000\000"
|
22
|
+
Mail::Encodings::QuotedPrintable.decode("=00=00=00=00").should == result
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,664 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Mail::Encodings do
|
5
|
+
|
6
|
+
describe "base64 Encoding" do
|
7
|
+
|
8
|
+
it "should return true for base64" do
|
9
|
+
Mail::Encodings.defined?('base64').should be_true
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should return true for Base64" do
|
13
|
+
Mail::Encodings.defined?('Base64').should be_true
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return true for :base64" do
|
17
|
+
Mail::Encodings.defined?(:base64).should be_true
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should return the Base64 Encoding class" do
|
21
|
+
Mail::Encodings.get_encoding('Base64').should == Mail::Encodings::Base64
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should return the base64 Encoding class" do
|
25
|
+
Mail::Encodings.get_encoding('base64').should == Mail::Encodings::Base64
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should return the base64 Encoding class" do
|
29
|
+
Mail::Encodings.get_encoding(:base64).should == Mail::Encodings::Base64
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "quoted-printable Encoding" do
|
35
|
+
|
36
|
+
it "should return true for quoted-printable" do
|
37
|
+
Mail::Encodings.defined?('quoted-printable').should be_true
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should return true for Quoted-Printable" do
|
41
|
+
Mail::Encodings.defined?('Quoted-Printable').should be_true
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should return true for :quoted_printable" do
|
45
|
+
Mail::Encodings.defined?(:quoted_printable).should be_true
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should return the QuotedPrintable Encoding class" do
|
49
|
+
Mail::Encodings.get_encoding('quoted-printable').should == Mail::Encodings::QuotedPrintable
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should return the QuotedPrintable Encoding class" do
|
53
|
+
Mail::Encodings.get_encoding('Quoted-Printable').should == Mail::Encodings::QuotedPrintable
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should return the QuotedPrintable Encoding class" do
|
57
|
+
Mail::Encodings.get_encoding(:quoted_printable).should == Mail::Encodings::QuotedPrintable
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "B encodings" do
|
63
|
+
# From rfc2047:
|
64
|
+
# From: =?US-ASCII?Q?Keith_Moore?= <moore@cs.utk.edu>
|
65
|
+
# To: =?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@dkuug.dk>
|
66
|
+
# CC: =?ISO-8859-1?Q?Andr=E9?= Pirard <PIRARD@vm1.ulg.ac.be>
|
67
|
+
# Subject: =?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?=
|
68
|
+
# =?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?=
|
69
|
+
#
|
70
|
+
# Note: In the first 'encoded-word' of the Subject field above, the
|
71
|
+
# last "=" at the end of the 'encoded-text' is necessary because each
|
72
|
+
# 'encoded-word' must be self-contained (the "=" character completes a
|
73
|
+
# group of 4 base64 characters representing 2 octets). An additional
|
74
|
+
# octet could have been encoded in the first 'encoded-word' (so that
|
75
|
+
# the encoded-word would contain an exact multiple of 3 encoded
|
76
|
+
# octets), except that the second 'encoded-word' uses a different
|
77
|
+
# 'charset' than the first one.
|
78
|
+
#
|
79
|
+
it "should just return the string if us-ascii and asked to B encoded string" do
|
80
|
+
if RUBY_VERSION >= "1.9.1"
|
81
|
+
string = "This is a string"
|
82
|
+
string = string.force_encoding('US-ASCII')
|
83
|
+
Mail::Encodings.b_value_encode(string).should == "This is a string"
|
84
|
+
else
|
85
|
+
string = "This is a string"
|
86
|
+
encoding = 'US-ASCII'
|
87
|
+
Mail::Encodings.b_value_encode(string, encoding).should == "This is a string"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should accept other encodings" do
|
92
|
+
if RUBY_VERSION >= "1.9.1"
|
93
|
+
string = "This is あ string"
|
94
|
+
string = string.force_encoding('UTF-8')
|
95
|
+
Mail::Encodings.b_value_encode(string).should == '=?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?='
|
96
|
+
else
|
97
|
+
string = "This is あ string"
|
98
|
+
encoding = 'UTF-8'
|
99
|
+
Mail::Encodings.b_value_encode(string, encoding).should == '=?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?='
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should complain if there is no encoding passed for Ruby < 1.9" do
|
104
|
+
if RUBY_VERSION >= "1.9.1"
|
105
|
+
string = "This is あ string"
|
106
|
+
string = string.force_encoding('UTF-8')
|
107
|
+
doing {Mail::Encodings.b_value_encode(string)}.should_not raise_error
|
108
|
+
else
|
109
|
+
string = "This is あ string"
|
110
|
+
encoding = 'UTF-8'
|
111
|
+
doing {Mail::Encodings.b_value_encode(string, nil)}.should raise_error("Must supply an encoding")
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should split the string up into bite sized chunks that can be wrapped easily" do
|
116
|
+
if RUBY_VERSION >= "1.9.1"
|
117
|
+
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"
|
118
|
+
string = string.force_encoding('UTF-8')
|
119
|
+
Mail::Encodings.b_value_encode(string).should == '=?UTF-8?B?VGhpcyBpcyDjgYIgcmVhbGx5IGxvbmcgc3RyaW5nIFRoaXMgaXMg44GCIHJl?= =?UTF-8?B?YWxseSBsb25nIHN0cmluZyBUaGlzIGlzIOOBgiByZWFsbHkgbG9uZyBzdHJp?= =?UTF-8?B?bmcgVGhpcyBpcyDjgYIgcmVhbGx5IGxvbmcgc3RyaW5nIFRoaXMgaXMg44GC?= =?UTF-8?B?IHJlYWxseSBsb25nIHN0cmluZw==?='
|
120
|
+
else
|
121
|
+
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"
|
122
|
+
encoding = 'UTF-8'
|
123
|
+
Mail::Encodings.b_value_encode(string, encoding).should == '=?UTF-8?B?VGhpcyBpcyDjgYIgcmVhbGx5IGxvbmcgc3RyaW5nIFRoaXMgaXMg44GCIHJl?= =?UTF-8?B?YWxseSBsb25nIHN0cmluZyBUaGlzIGlzIOOBgiByZWFsbHkgbG9uZyBzdHJp?= =?UTF-8?B?bmcgVGhpcyBpcyDjgYIgcmVhbGx5IGxvbmcgc3RyaW5nIFRoaXMgaXMg44GC?= =?UTF-8?B?IHJlYWxseSBsb25nIHN0cmluZw==?='
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should decode an encoded string" do
|
128
|
+
string = '=?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?='
|
129
|
+
result = "This is あ string"
|
130
|
+
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9'
|
131
|
+
Mail::Encodings.value_decode(string).should == result
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should decode a long encoded string" do
|
135
|
+
string = '=?UTF-8?B?VGhpcyBpcyDjgYIgcmVhbGx5IGxvbmcgc3RyaW5nIFRoaXMgaXMg44GCIHJl?= =?UTF-8?B?YWxseSBsb25nIHN0cmluZyBUaGlzIGlzIOOBgiByZWFsbHkgbG9uZyBzdHJp?= =?UTF-8?B?bmcgVGhpcyBpcyDjgYIgcmVhbGx5IGxvbmcgc3RyaW5nIFRoaXMgaXMg44GC?= =?UTF-8?B?IHJlYWxseSBsb25nIHN0cmluZw==?='
|
136
|
+
result = "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"
|
137
|
+
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9'
|
138
|
+
Mail::Encodings.value_decode(string).should == result
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
describe "Q encodings" do
|
144
|
+
# From rfc2047:
|
145
|
+
# From: =?US-ASCII?Q?Keith_Moore?= <moore@cs.utk.edu>
|
146
|
+
# To: =?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@dkuug.dk>
|
147
|
+
# CC: =?ISO-8859-1?Q?Andr=E9?= Pirard <PIRARD@vm1.ulg.ac.be>
|
148
|
+
# Subject: =?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?=
|
149
|
+
# =?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?=
|
150
|
+
#
|
151
|
+
# Note: In the first 'encoded-word' of the Subject field above, the
|
152
|
+
# last "=" at the end of the 'encoded-text' is necessary because each
|
153
|
+
# 'encoded-word' must be self-contained (the "=" character completes a
|
154
|
+
# group of 4 base64 characters representing 2 octets). An additional
|
155
|
+
# octet could have been encoded in the first 'encoded-word' (so that
|
156
|
+
# the encoded-word would contain an exact multiple of 3 encoded
|
157
|
+
# octets), except that the second 'encoded-word' uses a different
|
158
|
+
# 'charset' than the first one.
|
159
|
+
#
|
160
|
+
it "should just return the string if us-ascii and asked to Q encoded string" do
|
161
|
+
if RUBY_VERSION >= "1.9.1"
|
162
|
+
string = "This is a string"
|
163
|
+
string = string.force_encoding('US-ASCII')
|
164
|
+
Mail::Encodings.q_value_encode(string).should == "This is a string"
|
165
|
+
else
|
166
|
+
string = "This is a string"
|
167
|
+
encoding = 'US-ASCII'
|
168
|
+
Mail::Encodings.q_value_encode(string, encoding).should == "This is a string"
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should complain if there is no encoding passed for Ruby < 1.9" do
|
173
|
+
if RUBY_VERSION >= "1.9.1"
|
174
|
+
string = "This is あ string"
|
175
|
+
string = string.force_encoding('UTF-8')
|
176
|
+
doing {Mail::Encodings.q_value_encode(string)}.should_not raise_error
|
177
|
+
else
|
178
|
+
string = "This is あ string"
|
179
|
+
encoding = 'UTF-8'
|
180
|
+
doing {Mail::Encodings.q_value_encode(string)}.should raise_error("Must supply an encoding")
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
it "should accept other character sets" do
|
185
|
+
if RUBY_VERSION >= "1.9.1"
|
186
|
+
string = "This is あ string"
|
187
|
+
string = string.force_encoding('UTF-8')
|
188
|
+
Mail::Encodings.q_value_encode(string).should == '=?UTF-8?Q?This_is_=E3=81=82_string=?='
|
189
|
+
else
|
190
|
+
string = "This is あ string"
|
191
|
+
encoding = 'UTF-8'
|
192
|
+
Mail::Encodings.q_value_encode(string, encoding).should == '=?UTF-8?Q?This_is_=E3=81=82_string=?='
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
it "should decode an encoded string" do
|
197
|
+
string = '=?UTF-8?Q?This_is_=E3=81=82_string?='
|
198
|
+
result = "This is あ string"
|
199
|
+
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9'
|
200
|
+
Mail::Encodings.value_decode(string).should == result
|
201
|
+
end
|
202
|
+
|
203
|
+
it "should detect a q encoded string and decode it" do
|
204
|
+
string = '=?UTF-8?Q?This_is_=E3=81=82_string?='
|
205
|
+
result = "This is あ string"
|
206
|
+
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9'
|
207
|
+
Mail::Encodings.value_decode(string).should == result
|
208
|
+
end
|
209
|
+
|
210
|
+
it "should not fold a long string that has no spaces" do
|
211
|
+
original = "ВосстановлениеВосстановлениеВашегопароля"
|
212
|
+
if RUBY_VERSION >= '1.9'
|
213
|
+
original.force_encoding('UTF-8')
|
214
|
+
result = "Subject: =?UTF8?Q?=D0=92=D0=BE=D1=81=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=D0=92=D0=BE=D1=81=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=D0=92=D0=B0=D1=88=D0=B5=D0=B3=D0=BE=D0=BF=D0=B0=D1=80=D0=BE=D0=BB=D1=8F=?=\r\n"
|
215
|
+
else
|
216
|
+
result = "Subject: =?UTF8?Q?=D0=92=D0=BE=D1=81=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=D0=92=D0=BE=D1=81=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=D0=92=D0=B0=D1=88=D0=B5=D0=B3=D0=BE=D0=BF=D0=B0=D1=80=D0=BE=D0=BB=D1=8F=?=\r\n"
|
217
|
+
end
|
218
|
+
mail = Mail.new
|
219
|
+
mail.subject = original
|
220
|
+
mail[:subject].decoded.should == original
|
221
|
+
mail[:subject].encoded.gsub("UTF-8", "UTF8").should == result
|
222
|
+
end
|
223
|
+
|
224
|
+
it "should round trip a complex string properly" do
|
225
|
+
original = "ВосстановлениеВосстановлениеВашегопароля This is a NUT?????Z__string that== could (break) anything"
|
226
|
+
if RUBY_VERSION >= '1.9'
|
227
|
+
original.force_encoding('UTF-8')
|
228
|
+
end
|
229
|
+
result = "Subject: =?UTF8?Q?=D0=92=D0=BE=D1=81=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=D0=92=D0=BE=D1=81=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=D0=92=D0=B0=D1=88=D0=B5=D0=B3=D0=BE=D0=BF=D0=B0=D1=80=D0=BE=D0=BB=D1=8F=?=\r\n\tThis is a NUT?????Z__string that== could (break) anything\r\n"
|
230
|
+
mail = Mail.new
|
231
|
+
mail.subject = original
|
232
|
+
mail[:subject].decoded.should == original
|
233
|
+
mail[:subject].encoded.gsub("UTF-8", "UTF8").should == result
|
234
|
+
mail = Mail.new(mail.encoded)
|
235
|
+
mail[:subject].decoded.should == original
|
236
|
+
mail[:subject].encoded.gsub("UTF-8", "UTF8").should == result
|
237
|
+
mail = Mail.new(mail.encoded)
|
238
|
+
mail[:subject].decoded.should == original
|
239
|
+
mail[:subject].encoded.gsub("UTF-8", "UTF8").should == result
|
240
|
+
end
|
241
|
+
|
242
|
+
end
|
243
|
+
|
244
|
+
describe "parameter MIME encodings" do
|
245
|
+
# Character set and language information may be combined with the
|
246
|
+
# parameter continuation mechanism. For example:
|
247
|
+
#
|
248
|
+
# Content-Type: application/x-stuff
|
249
|
+
# title*0*=us-ascii'en'This%20is%20even%20more%20
|
250
|
+
# title*1*=%2A%2A%2Afun%2A%2A%2A%20
|
251
|
+
# title*2="isn't it!"
|
252
|
+
#
|
253
|
+
# Note that:
|
254
|
+
#
|
255
|
+
# (1) Language and character set information only appear at
|
256
|
+
# the beginning of a given parameter value.
|
257
|
+
#
|
258
|
+
# (2) Continuations do not provide a facility for using more
|
259
|
+
# than one character set or language in the same
|
260
|
+
# parameter value.
|
261
|
+
#
|
262
|
+
# (3) A value presented using multiple continuations may
|
263
|
+
# contain a mixture of encoded and unencoded segments.
|
264
|
+
#
|
265
|
+
# (4) The first segment of a continuation MUST be encoded if
|
266
|
+
# language and character set information are given.
|
267
|
+
#
|
268
|
+
# (5) If the first segment of a continued parameter value is
|
269
|
+
# encoded the language and character set field delimiters
|
270
|
+
# MUST be present even when the fields are left blank.
|
271
|
+
#
|
272
|
+
|
273
|
+
before(:each) do
|
274
|
+
Mail.defaults do
|
275
|
+
param_encode_language('en')
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
it "should leave an unencoded string alone" do
|
280
|
+
string = "this isn't encoded"
|
281
|
+
result = "this isn't encoded"
|
282
|
+
Mail::Encodings.param_decode(string, 'us-ascii').should == result
|
283
|
+
end
|
284
|
+
|
285
|
+
it "should unencode an encoded string" do
|
286
|
+
string = "This%20is%20even%20more%20"
|
287
|
+
result = "This is even more "
|
288
|
+
result.force_encoding('us-ascii') if RUBY_VERSION >= '1.9'
|
289
|
+
Mail::Encodings.param_decode(string, 'us-ascii').should == result
|
290
|
+
end
|
291
|
+
|
292
|
+
it "should unencoded an encoded string and return the right charset on 1.9" do
|
293
|
+
string = "This%20is%20even%20more%20"
|
294
|
+
result = "This is even more "
|
295
|
+
result.force_encoding('us-ascii') if RUBY_VERSION >= '1.9'
|
296
|
+
Mail::Encodings.param_decode(string, 'us-ascii').should == result
|
297
|
+
end
|
298
|
+
|
299
|
+
it "should unencode a complete string that included unencoded parts" do
|
300
|
+
string = "This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20isn't it"
|
301
|
+
result = "This is even more ***fun*** isn't it"
|
302
|
+
result.force_encoding('iso-8859-1') if RUBY_VERSION >= '1.9'
|
303
|
+
Mail::Encodings.param_decode(string, 'iso-8859-1').should == result
|
304
|
+
end
|
305
|
+
|
306
|
+
it "should encode a string" do
|
307
|
+
string = "This is あ string"
|
308
|
+
if RUBY_VERSION >= '1.9'
|
309
|
+
Mail::Encodings.param_encode(string).should == "utf-8'en'This%20is%20%20%E3%81%82%20string"
|
310
|
+
else
|
311
|
+
Mail::Encodings.param_encode(string).should == "utf8'en'This%20is%20%20%E3%81%82%20string"
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
it "should just quote US-ASCII with spaces" do
|
316
|
+
string = "This is even more"
|
317
|
+
if RUBY_VERSION >= '1.9'
|
318
|
+
Mail::Encodings.param_encode(string).should == '"This is even more"'
|
319
|
+
else
|
320
|
+
Mail::Encodings.param_encode(string).should == '"This is even more"'
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
it "should leave US-ASCII without spaces alone" do
|
325
|
+
string = "fun"
|
326
|
+
if RUBY_VERSION >= '1.9'
|
327
|
+
Mail::Encodings.param_encode(string).should == 'fun'
|
328
|
+
else
|
329
|
+
Mail::Encodings.param_encode(string).should == 'fun'
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
end
|
334
|
+
|
335
|
+
describe "decoding a string and detecting the encoding type" do
|
336
|
+
|
337
|
+
it "should detect an encoded Base64 string to the decoded string" do
|
338
|
+
string = '=?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?='
|
339
|
+
result = "This is あ string"
|
340
|
+
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9'
|
341
|
+
Mail::Encodings.value_decode(string).should == result
|
342
|
+
end
|
343
|
+
|
344
|
+
it "should detect a multiple encoded Base64 string to the decoded string" do
|
345
|
+
string = '=?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?==?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?='
|
346
|
+
result = "This is あ stringThis is あ string"
|
347
|
+
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9'
|
348
|
+
Mail::Encodings.value_decode(string).should == result
|
349
|
+
end
|
350
|
+
|
351
|
+
it "should detect a multiple encoded Base64 string with a space to the decoded string" do
|
352
|
+
string = '=?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?= =?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?='
|
353
|
+
result = "This is あ stringThis is あ string"
|
354
|
+
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9'
|
355
|
+
Mail::Encodings.value_decode(string).should == result
|
356
|
+
end
|
357
|
+
|
358
|
+
it "should detect a multiple encoded Base64 string with a whitespace to the decoded string" do
|
359
|
+
string = "=?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?= \r\n\t=?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?="
|
360
|
+
result = "This is あ stringThis is あ string"
|
361
|
+
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9'
|
362
|
+
Mail::Encodings.value_decode(string).should == result
|
363
|
+
end
|
364
|
+
|
365
|
+
it "should decode B and Q encodings together if needed" do
|
366
|
+
string = "=?UTF-8?Q?This_is_=E3=81=82_string?==?UTF-8?Q?This_is_=E3=81=82_string?= Some non encoded stuff =?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?= \r\n\tMore non encoded stuff"
|
367
|
+
result = "This is あ stringThis is あ string Some non encoded stuff This is あ string \r\n\tMore non encoded stuff"
|
368
|
+
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9'
|
369
|
+
Mail::Encodings.value_decode(string).should == result
|
370
|
+
end
|
371
|
+
|
372
|
+
it "should detect a encoded and unencoded Base64 string to the decoded string" do
|
373
|
+
string = "Some non encoded stuff =?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?= \r\n\tMore non encoded stuff"
|
374
|
+
result = "Some non encoded stuff This is あ string \r\n\tMore non encoded stuff"
|
375
|
+
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9'
|
376
|
+
Mail::Encodings.value_decode(string).should == result
|
377
|
+
end
|
378
|
+
|
379
|
+
it "should detect an encoded QP string to the decoded string" do
|
380
|
+
string = '=?UTF-8?Q?This_is_=E3=81=82_string?='
|
381
|
+
result = "This is あ string"
|
382
|
+
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9'
|
383
|
+
Mail::Encodings.value_decode(string).should == result
|
384
|
+
end
|
385
|
+
|
386
|
+
it "should detect multiple encoded QP string to the decoded string" do
|
387
|
+
string = '=?UTF-8?Q?This_is_=E3=81=82_string?==?UTF-8?Q?This_is_=E3=81=82_string?='
|
388
|
+
result = "This is あ stringThis is あ string"
|
389
|
+
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9'
|
390
|
+
Mail::Encodings.value_decode(string).should == result
|
391
|
+
end
|
392
|
+
|
393
|
+
it "should detect multiple encoded QP string with a space to the decoded string" do
|
394
|
+
string = '=?UTF-8?Q?This_is_=E3=81=82_string?= =?UTF-8?Q?This_is_=E3=81=82_string?='
|
395
|
+
result = "This is あ stringThis is あ string"
|
396
|
+
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9'
|
397
|
+
Mail::Encodings.value_decode(string).should == result
|
398
|
+
end
|
399
|
+
|
400
|
+
it "should detect multiple encoded QP string with a space to the decoded string" do
|
401
|
+
string = "=?UTF-8?Q?This_is_=E3=81=82_string?= \r\n\t=?UTF-8?Q?This_is_=E3=81=82_string?="
|
402
|
+
result = "This is あ stringThis is あ string"
|
403
|
+
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9'
|
404
|
+
Mail::Encodings.value_decode(string).should == result
|
405
|
+
end
|
406
|
+
|
407
|
+
it "should detect a encoded and unencoded QP string to the decoded string" do
|
408
|
+
string = "Some non encoded stuff =?UTF-8?Q?This_is_=E3=81=82_string?= \r\n\tMore non encoded stuff"
|
409
|
+
result = "Some non encoded stuff This is あ string \r\n\tMore non encoded stuff"
|
410
|
+
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9'
|
411
|
+
Mail::Encodings.value_decode(string).should == result
|
412
|
+
end
|
413
|
+
|
414
|
+
it "should detect a plain string and return it" do
|
415
|
+
string = 'This is あ string'
|
416
|
+
result = "This is あ string"
|
417
|
+
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9'
|
418
|
+
Mail::Encodings.value_decode(string).should == result
|
419
|
+
end
|
420
|
+
|
421
|
+
end
|
422
|
+
|
423
|
+
describe "altering an encoded text to decoded and visa versa" do
|
424
|
+
|
425
|
+
describe "decoding" do
|
426
|
+
|
427
|
+
before(:each) do
|
428
|
+
@original = $KCODE if RUBY_VERSION < '1.9'
|
429
|
+
end
|
430
|
+
|
431
|
+
after(:each) do
|
432
|
+
$KCODE = @original if RUBY_VERSION < '1.9'
|
433
|
+
end
|
434
|
+
|
435
|
+
it "should detect an encoded Base64 string and return the decoded string" do
|
436
|
+
string = '=?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?='
|
437
|
+
result = "This is あ string"
|
438
|
+
if RUBY_VERSION >= '1.9'
|
439
|
+
result.force_encoding('UTF-8')
|
440
|
+
else
|
441
|
+
$KCODE = 'UTF-8'
|
442
|
+
end
|
443
|
+
Mail::Encodings.decode_encode(string, :decode).should == result
|
444
|
+
end
|
445
|
+
|
446
|
+
it "should detect an encoded QP string and return the decoded string" do
|
447
|
+
string = '=?UTF-8?Q?This_is_=E3=81=82_string?='
|
448
|
+
result = "This is あ string"
|
449
|
+
if RUBY_VERSION >= '1.9'
|
450
|
+
result.force_encoding('UTF-8')
|
451
|
+
else
|
452
|
+
$KCODE = 'UTF-8'
|
453
|
+
end
|
454
|
+
Mail::Encodings.decode_encode(string, :decode).should == result
|
455
|
+
end
|
456
|
+
|
457
|
+
it "should detect an a string is already decoded and leave it alone" do
|
458
|
+
string = 'This is あ string'
|
459
|
+
result = "This is あ string"
|
460
|
+
if RUBY_VERSION >= '1.9'
|
461
|
+
result.force_encoding('UTF-8')
|
462
|
+
else
|
463
|
+
$KCODE = 'UTF-8'
|
464
|
+
end
|
465
|
+
Mail::Encodings.decode_encode(string, :decode).should == result
|
466
|
+
end
|
467
|
+
|
468
|
+
end
|
469
|
+
|
470
|
+
describe "encoding" do
|
471
|
+
|
472
|
+
it "should encode a string into Base64" do
|
473
|
+
string = "This is あ string"
|
474
|
+
if RUBY_VERSION >= '1.9'
|
475
|
+
result = '=?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?='
|
476
|
+
result.force_encoding('UTF-8')
|
477
|
+
else
|
478
|
+
result = '=?UTF8?B?VGhpcyBpcyDjgYIgc3RyaW5n?='
|
479
|
+
$KCODE = 'UTF-8'
|
480
|
+
end
|
481
|
+
Mail::Encodings.decode_encode(string, :encode).should == result
|
482
|
+
end
|
483
|
+
|
484
|
+
it "should leave a string that doesn't need encoding alone" do
|
485
|
+
string = 'This is a string'
|
486
|
+
result = "This is a string"
|
487
|
+
if RUBY_VERSION >= '1.9'
|
488
|
+
result.force_encoding('UTF-8')
|
489
|
+
else
|
490
|
+
$KCODE = 'UTF-8'
|
491
|
+
end
|
492
|
+
Mail::Encodings.decode_encode(string, :encode).should == result
|
493
|
+
end
|
494
|
+
|
495
|
+
end
|
496
|
+
|
497
|
+
describe "unquote and convert to" do
|
498
|
+
it "should unquote quoted printable and convert to utf-8" do
|
499
|
+
a ="=?ISO-8859-1?Q?[166417]_Bekr=E6ftelse_fra_Rejsefeber?="
|
500
|
+
b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8')
|
501
|
+
b.should == "[166417] Bekr\303\246ftelse fra Rejsefeber"
|
502
|
+
end
|
503
|
+
|
504
|
+
it "should unquote base64 and convert to utf-8" do
|
505
|
+
a ="=?ISO-8859-1?B?WzE2NjQxN10gQmVrcuZmdGVsc2UgZnJhIFJlanNlZmViZXI=?="
|
506
|
+
b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8')
|
507
|
+
b.should == "[166417] Bekr\303\246ftelse fra Rejsefeber"
|
508
|
+
end
|
509
|
+
|
510
|
+
it "should handle no charset" do
|
511
|
+
a ="[166417]_Bekr=E6ftelse_fra_Rejsefeber"
|
512
|
+
b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8')
|
513
|
+
b.should == "[166417]_Bekr=E6ftelse_fra_Rejsefeber"
|
514
|
+
end
|
515
|
+
|
516
|
+
it "should unquote multiple lines" do
|
517
|
+
a ="=?utf-8?q?Re=3A_=5B12=5D_=23137=3A_Inkonsistente_verwendung_von_=22Hin?==?utf-8?b?enVmw7xnZW4i?="
|
518
|
+
b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8')
|
519
|
+
b.should == "Re: [12] #137: Inkonsistente verwendung von \"Hinzuf\303\274gen\""
|
520
|
+
end
|
521
|
+
|
522
|
+
it "should unquote a string in the middle of the text" do
|
523
|
+
a ="Re: Photos =?ISO-8859-1?Q?Brosch=FCre_Rand?="
|
524
|
+
b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8')
|
525
|
+
b.should == "Re: Photos Brosch\303\274re Rand"
|
526
|
+
end
|
527
|
+
|
528
|
+
it "should unquote and change to an ISO encoding if we really want" do
|
529
|
+
a ="=?ISO-8859-1?Q?Brosch=FCre_Rand?="
|
530
|
+
b = Mail::Encodings.unquote_and_convert_to(a, 'iso-8859-1')
|
531
|
+
expected = "Brosch\374re Rand"
|
532
|
+
expected.force_encoding 'iso-8859-1' if expected.respond_to?(:force_encoding)
|
533
|
+
b.should == expected
|
534
|
+
end
|
535
|
+
|
536
|
+
it "should unquote multiple strings in the middle of the text" do
|
537
|
+
a = "=?Shift_JIS?Q?=93=FA=96{=8C=EA=?= <a@example.com>, =?Shift_JIS?Q?=93=FA=96{=8C=EA=?= <b@example.com>"
|
538
|
+
b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8')
|
539
|
+
b.should == "日本語 <a@example.com>, 日本語 <b@example.com>"
|
540
|
+
end
|
541
|
+
end
|
542
|
+
end
|
543
|
+
|
544
|
+
describe "quoted printable encoding and decoding" do
|
545
|
+
it "should handle underscores in the text" do
|
546
|
+
expected = 'something_with_underscores'
|
547
|
+
encoded = [expected].pack('*M')
|
548
|
+
Mail::Encodings.get_encoding(:quoted_printable).encode(expected).unpack("*M").first.should == expected
|
549
|
+
end
|
550
|
+
|
551
|
+
it "should handle underscores in the text" do
|
552
|
+
expected = 'something with_underscores'
|
553
|
+
encoded = [expected].pack('*M')
|
554
|
+
Mail::Encodings.get_encoding(:quoted_printable).encode(expected).unpack("*M").first.should == expected
|
555
|
+
end
|
556
|
+
|
557
|
+
it "should keep the underscores in the text" do
|
558
|
+
expected = 'something_with_underscores'
|
559
|
+
encoded = Mail::Encodings.get_encoding(:quoted_printable).encode(expected)
|
560
|
+
Mail::Encodings.get_encoding(:quoted_printable).decode(encoded).should == expected
|
561
|
+
end
|
562
|
+
|
563
|
+
it "should handle a new line in the text" do
|
564
|
+
if RUBY_VERSION >= '1.9'
|
565
|
+
expected = "\nRe: ol\341".force_encoding('ISO-8859-1')
|
566
|
+
else
|
567
|
+
expected = "\nRe: ol\341"
|
568
|
+
end
|
569
|
+
encoded = "=?ISO-8859-1?Q?\nRe=3A_ol=E1?="
|
570
|
+
Mail::Encodings.value_decode(encoded).should == expected
|
571
|
+
end
|
572
|
+
|
573
|
+
end
|
574
|
+
|
575
|
+
describe "pre encoding non usascii text" do
|
576
|
+
it "should not change an ascii string" do
|
577
|
+
raw = 'mikel@test.lindsaar.net'
|
578
|
+
Mail::Encodings.encode_non_usascii(raw, 'utf-8').should == raw
|
579
|
+
end
|
580
|
+
|
581
|
+
it "should encode a display that contains non usascii" do
|
582
|
+
raw = 'Lindsああr <mikel@test.lindsaar.net>'
|
583
|
+
encoded = '=?UTF-8?B?TGluZHPjgYLjgYJy?= <mikel@test.lindsaar.net>'
|
584
|
+
Mail::Encodings.encode_non_usascii(raw, 'utf-8').should == encoded
|
585
|
+
end
|
586
|
+
|
587
|
+
it "should encode a display that contains non usascii with quotes as no quotes" do
|
588
|
+
raw = '"Lindsああr" <mikel@test.lindsaar.net>'
|
589
|
+
encoded = '=?UTF-8?B?TGluZHPjgYLjgYJy?= <mikel@test.lindsaar.net>'
|
590
|
+
Mail::Encodings.encode_non_usascii(raw, 'utf-8').should == encoded
|
591
|
+
end
|
592
|
+
|
593
|
+
it "should encode a display name with us-ascii and non-usascii parts" do
|
594
|
+
raw = 'Mikel Lindsああr <mikel@test.lindsaar.net>'
|
595
|
+
encoded = 'Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <mikel@test.lindsaar.net>'
|
596
|
+
Mail::Encodings.encode_non_usascii(raw, 'utf-8').should == encoded
|
597
|
+
end
|
598
|
+
|
599
|
+
it "should encode a display name with us-ascii and non-usascii parts ignoring quotes" do
|
600
|
+
raw = '"Mikel Lindsああr" <mikel@test.lindsaar.net>'
|
601
|
+
encoded = '=?UTF-8?B?TWlrZWwgTGluZHPjgYLjgYJy?= <mikel@test.lindsaar.net>'
|
602
|
+
Mail::Encodings.encode_non_usascii(raw, 'utf-8').should == encoded
|
603
|
+
end
|
604
|
+
|
605
|
+
it "should encode multiple addresses correctly" do
|
606
|
+
raw = '"Mikel Lindsああr" <mikel@test.lindsaar.net>, "あdあ" <ada@test.lindsaar.net>'
|
607
|
+
encoded = '=?UTF-8?B?TWlrZWwgTGluZHPjgYLjgYJy?= <mikel@test.lindsaar.net>, =?UTF-8?B?44GCZOOBgg==?= <ada@test.lindsaar.net>'
|
608
|
+
Mail::Encodings.encode_non_usascii(raw, 'utf-8').should == encoded
|
609
|
+
end
|
610
|
+
|
611
|
+
it "should encode multiple unquoted addresses correctly" do
|
612
|
+
raw = 'Mikel Lindsああr <mikel@test.lindsaar.net>, あdあ <ada@test.lindsaar.net>'
|
613
|
+
encoded = 'Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <mikel@test.lindsaar.net>, =?UTF-8?B?44GCZOOBgg==?= <ada@test.lindsaar.net>'
|
614
|
+
Mail::Encodings.encode_non_usascii(raw, 'utf-8').should == encoded
|
615
|
+
end
|
616
|
+
|
617
|
+
it "should encode multiple un bracketed addresses and groups correctly" do
|
618
|
+
raw = '"Mikel Lindsああr" test1@lindsaar.net, group: "あdあ" test2@lindsaar.net, me@lindsaar.net;'
|
619
|
+
encoded = '=?UTF-8?B?TWlrZWwgTGluZHPjgYLjgYJy?= test1@lindsaar.net, group: =?UTF-8?B?44GCZOOBgg==?= test2@lindsaar.net, me@lindsaar.net;'
|
620
|
+
Mail::Encodings.encode_non_usascii(raw, 'utf-8').should == encoded
|
621
|
+
end
|
622
|
+
|
623
|
+
end
|
624
|
+
|
625
|
+
describe "address encoding" do
|
626
|
+
it "should not do anything to a plain address" do
|
627
|
+
raw = 'mikel@test.lindsaar.net'
|
628
|
+
encoded = 'mikel@test.lindsaar.net'
|
629
|
+
Mail::Encodings.address_encode(raw, 'utf-8').should == encoded
|
630
|
+
end
|
631
|
+
|
632
|
+
it "should encode an address correctly" do
|
633
|
+
raw = '"Mikel Lindsああr" <mikel@test.lindsaar.net>'
|
634
|
+
encoded = '=?UTF-8?B?TWlrZWwgTGluZHPjgYLjgYJy?= <mikel@test.lindsaar.net>'
|
635
|
+
Mail::Encodings.address_encode(raw, 'utf-8').should == encoded
|
636
|
+
end
|
637
|
+
|
638
|
+
it "should encode multiple addresses correctly" do
|
639
|
+
raw = ['"Mikel Lindsああr" <mikel@test.lindsaar.net>', '"あdあ" <ada@test.lindsaar.net>']
|
640
|
+
encoded = '=?UTF-8?B?TWlrZWwgTGluZHPjgYLjgYJy?= <mikel@test.lindsaar.net>, =?UTF-8?B?44GCZOOBgg==?= <ada@test.lindsaar.net>'
|
641
|
+
Mail::Encodings.address_encode(raw, 'utf-8').should == encoded
|
642
|
+
end
|
643
|
+
|
644
|
+
it "should handle a single ascii address correctly from a string" do
|
645
|
+
raw = ['"Mikel Lindsaar" <mikel@test.lindsaar.net>']
|
646
|
+
encoded = '"Mikel Lindsaar" <mikel@test.lindsaar.net>'
|
647
|
+
Mail::Encodings.address_encode(raw, 'utf-8').should == encoded
|
648
|
+
end
|
649
|
+
|
650
|
+
it "should handle multiple ascii addresses correctly from a string" do
|
651
|
+
raw = 'Mikel Lindsaar <mikel@test.lindsaar.net>, Ada <ada@test.lindsaar.net>'
|
652
|
+
encoded = 'Mikel Lindsaar <mikel@test.lindsaar.net>, Ada <ada@test.lindsaar.net>'
|
653
|
+
Mail::Encodings.address_encode(raw, 'utf-8').should == encoded
|
654
|
+
end
|
655
|
+
|
656
|
+
it "should handle ascii addresses correctly as an array" do
|
657
|
+
raw = ['Mikel Lindsaar <mikel@test.lindsaar.net>', 'Ada <ada@test.lindsaar.net>']
|
658
|
+
encoded = 'Mikel Lindsaar <mikel@test.lindsaar.net>, Ada <ada@test.lindsaar.net>'
|
659
|
+
Mail::Encodings.address_encode(raw, 'utf-8').should == encoded
|
660
|
+
end
|
661
|
+
|
662
|
+
end
|
663
|
+
|
664
|
+
end
|