mail 2.6.6 → 2.7.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.rdoc +25 -6
  3. data/Dependencies.txt +0 -1
  4. data/Gemfile +5 -8
  5. data/MIT-LICENSE +1 -1
  6. data/README.md +22 -11
  7. data/Rakefile +0 -6
  8. data/lib/mail.rb +2 -10
  9. data/lib/mail/attachments_list.rb +3 -2
  10. data/lib/mail/body.rb +3 -3
  11. data/lib/mail/core_extensions/smtp.rb +19 -16
  12. data/lib/mail/core_extensions/string.rb +0 -4
  13. data/lib/mail/elements/address.rb +9 -4
  14. data/lib/mail/elements/address_list.rb +10 -18
  15. data/lib/mail/elements/content_disposition_element.rb +8 -15
  16. data/lib/mail/elements/content_location_element.rb +5 -10
  17. data/lib/mail/elements/content_transfer_encoding_element.rb +5 -10
  18. data/lib/mail/elements/content_type_element.rb +8 -19
  19. data/lib/mail/elements/date_time_element.rb +6 -14
  20. data/lib/mail/elements/envelope_from_element.rb +14 -21
  21. data/lib/mail/elements/message_ids_element.rb +8 -12
  22. data/lib/mail/elements/mime_version_element.rb +6 -14
  23. data/lib/mail/elements/phrase_list.rb +6 -9
  24. data/lib/mail/elements/received_element.rb +9 -15
  25. data/lib/mail/encodings.rb +12 -14
  26. data/lib/mail/field.rb +7 -4
  27. data/lib/mail/fields/common/parameter_hash.rb +1 -1
  28. data/lib/mail/fields/content_type_field.rb +2 -7
  29. data/lib/mail/fields/unstructured_field.rb +2 -2
  30. data/lib/mail/header.rb +1 -0
  31. data/lib/mail/message.rb +23 -25
  32. data/lib/mail/multibyte.rb +51 -0
  33. data/lib/mail/multibyte/chars.rb +27 -27
  34. data/lib/mail/network/delivery_methods/exim.rb +10 -6
  35. data/lib/mail/network/delivery_methods/sendmail.rb +2 -6
  36. data/lib/mail/network/delivery_methods/smtp.rb +14 -6
  37. data/lib/mail/parsers.rb +16 -24
  38. data/lib/mail/parsers/address_lists_parser.rb +15321 -112
  39. data/lib/mail/parsers/address_lists_parser.rl +166 -0
  40. data/lib/mail/parsers/content_disposition_parser.rb +698 -55
  41. data/lib/mail/parsers/content_disposition_parser.rl +76 -0
  42. data/lib/mail/parsers/content_location_parser.rb +565 -23
  43. data/lib/mail/parsers/content_location_parser.rl +65 -0
  44. data/lib/mail/parsers/content_transfer_encoding_parser.rb +410 -22
  45. data/lib/mail/parsers/content_transfer_encoding_parser.rl +58 -0
  46. data/lib/mail/parsers/content_type_parser.rb +841 -54
  47. data/lib/mail/parsers/content_type_parser.rl +77 -0
  48. data/lib/mail/parsers/date_time_parser.rb +773 -26
  49. data/lib/mail/parsers/date_time_parser.rl +56 -0
  50. data/lib/mail/parsers/envelope_from_parser.rb +2051 -36
  51. data/lib/mail/parsers/envelope_from_parser.rl +76 -0
  52. data/lib/mail/parsers/message_ids_parser.rb +1494 -25
  53. data/lib/mail/parsers/message_ids_parser.rl +76 -0
  54. data/lib/mail/parsers/mime_version_parser.rb +393 -26
  55. data/lib/mail/parsers/mime_version_parser.rl +55 -0
  56. data/lib/mail/parsers/phrase_lists_parser.rb +529 -19
  57. data/lib/mail/parsers/phrase_lists_parser.rl +77 -0
  58. data/lib/mail/parsers/received_parser.rb +4711 -38
  59. data/lib/mail/parsers/received_parser.rl +78 -0
  60. data/lib/mail/parsers/rfc2045_content_transfer_encoding.rl +12 -0
  61. data/lib/mail/parsers/rfc2045_content_type.rl +24 -0
  62. data/lib/mail/parsers/rfc2045_mime.rl +15 -0
  63. data/lib/mail/parsers/rfc2183_content_disposition.rl +14 -0
  64. data/lib/mail/parsers/rfc5234_abnf_core_rules.rl +16 -0
  65. data/lib/mail/parsers/rfc5322.rl +57 -0
  66. data/lib/mail/parsers/rfc5322_address.rl +70 -0
  67. data/lib/mail/parsers/{ragel/date_time.rl → rfc5322_date_time.rl} +7 -1
  68. data/lib/mail/parsers/rfc5322_lexical_tokens.rl +56 -0
  69. data/lib/mail/part.rb +1 -1
  70. data/lib/mail/parts_list.rb +5 -6
  71. data/lib/mail/utilities.rb +4 -2
  72. data/lib/mail/version.rb +3 -3
  73. data/lib/mail/version_specific/ruby_1_8.rb +28 -2
  74. data/lib/mail/version_specific/ruby_1_9.rb +48 -8
  75. metadata +28 -45
  76. data/lib/mail/core_extensions/string/access.rb +0 -146
  77. data/lib/mail/core_extensions/string/multibyte.rb +0 -79
  78. data/lib/mail/parsers/ragel.rb +0 -18
  79. data/lib/mail/parsers/ragel/common.rl +0 -185
  80. data/lib/mail/parsers/ragel/parser_info.rb +0 -61
  81. data/lib/mail/parsers/ragel/ruby.rb +0 -40
  82. data/lib/mail/parsers/ragel/ruby/machines/address_lists_machine.rb +0 -14864
  83. data/lib/mail/parsers/ragel/ruby/machines/address_lists_machine.rb.rl +0 -37
  84. data/lib/mail/parsers/ragel/ruby/machines/content_disposition_machine.rb +0 -751
  85. data/lib/mail/parsers/ragel/ruby/machines/content_disposition_machine.rb.rl +0 -37
  86. data/lib/mail/parsers/ragel/ruby/machines/content_location_machine.rb +0 -614
  87. data/lib/mail/parsers/ragel/ruby/machines/content_location_machine.rb.rl +0 -37
  88. data/lib/mail/parsers/ragel/ruby/machines/content_transfer_encoding_machine.rb +0 -447
  89. data/lib/mail/parsers/ragel/ruby/machines/content_transfer_encoding_machine.rb.rl +0 -37
  90. data/lib/mail/parsers/ragel/ruby/machines/content_type_machine.rb +0 -825
  91. data/lib/mail/parsers/ragel/ruby/machines/content_type_machine.rb.rl +0 -37
  92. data/lib/mail/parsers/ragel/ruby/machines/date_time_machine.rb +0 -817
  93. data/lib/mail/parsers/ragel/ruby/machines/date_time_machine.rb.rl +0 -37
  94. data/lib/mail/parsers/ragel/ruby/machines/envelope_from_machine.rb +0 -2149
  95. data/lib/mail/parsers/ragel/ruby/machines/envelope_from_machine.rb.rl +0 -37
  96. data/lib/mail/parsers/ragel/ruby/machines/message_ids_machine.rb +0 -1570
  97. data/lib/mail/parsers/ragel/ruby/machines/message_ids_machine.rb.rl +0 -37
  98. data/lib/mail/parsers/ragel/ruby/machines/mime_version_machine.rb +0 -440
  99. data/lib/mail/parsers/ragel/ruby/machines/mime_version_machine.rb.rl +0 -37
  100. data/lib/mail/parsers/ragel/ruby/machines/phrase_lists_machine.rb +0 -564
  101. data/lib/mail/parsers/ragel/ruby/machines/phrase_lists_machine.rb.rl +0 -37
  102. data/lib/mail/parsers/ragel/ruby/machines/rb_actions.rl +0 -51
  103. data/lib/mail/parsers/ragel/ruby/machines/received_machine.rb +0 -5144
  104. data/lib/mail/parsers/ragel/ruby/machines/received_machine.rb.rl +0 -37
  105. data/lib/mail/parsers/ragel/ruby/parser.rb.rl.erb +0 -37
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+ require 'mail/utilities'
3
+
4
+ %%{
5
+ machine date_time;
6
+
7
+ # Received Tokens
8
+ action received_tokens_s { received_tokens_s = p }
9
+ action received_tokens_e { received.info = data[received_tokens_s..(p-1)] }
10
+
11
+ # Date
12
+ action date_s { date_s = p }
13
+ action date_e { received.date = data[date_s..(p-1)].strip }
14
+
15
+ # Time
16
+ action time_s { time_s = p }
17
+ action time_e { received.time = data[time_s..(p-1)] }
18
+
19
+ # No-op actions
20
+ action address_s {}
21
+ action address_e {}
22
+ action angle_addr_s {}
23
+ action ctime_date_s {}
24
+ action ctime_date_e {}
25
+ action comment_e {}
26
+ action comment_s {}
27
+ action phrase_s {}
28
+ action phrase_e {}
29
+ action domain_e {}
30
+ action domain_s {}
31
+ action local_dot_atom_e {}
32
+ action local_dot_atom_pre_comment_e {}
33
+ action local_dot_atom_pre_comment_s {}
34
+ action local_dot_atom_s {}
35
+ action qstr_e {}
36
+ action qstr_s {}
37
+ action local_quoted_string_s {}
38
+ action local_quoted_string_e {}
39
+ action obs_domain_list_s {}
40
+ action obs_domain_list_e {}
41
+ action group_name_s {}
42
+ action group_name_e {}
43
+ action msg_id_s {}
44
+ action msg_id_e {}
45
+
46
+ include rfc5322 "rfc5322.rl";
47
+ main := received;
48
+ }%%
49
+
50
+ module Mail::Parsers
51
+ module ReceivedParser
52
+ ReceivedStruct = Struct.new(:date, :time, :info, :error)
53
+
54
+ %%write data noprefix;
55
+
56
+ def self.parse(data)
57
+ raise Mail::Field::ParseError.new(Mail::ReceivedElement, data, 'nil is invalid') if data.nil?
58
+
59
+ # Parser state
60
+ received = ReceivedStruct.new
61
+ received_tokens_s = date_s = time_s = nil
62
+
63
+ # 5.1 Variables Used by Ragel
64
+ p = 0
65
+ eof = pe = data.length
66
+ stack = []
67
+
68
+ %%write init;
69
+ %%write exec;
70
+
71
+ if p != eof || cs < %%{ write first_final; }%%
72
+ raise Mail::Field::ParseError.new(Mail::ReceivedElement, data, "Only able to parse up to #{data[0..p]}")
73
+ end
74
+
75
+ received
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,12 @@
1
+ %%{
2
+ # RFC 2045 Section 6.1: Content-Transfer-Encoding Header Field
3
+ # https://tools.ietf.org/html/rfc2045#section-6.1
4
+ machine rfc2045_content_transfer_encoding;
5
+
6
+ include rfc2045_content_type "rfc2045_content_type.rl";
7
+
8
+ encoding = ('7bits' | '8bits' | '7bit' | '8bit' | 'binary' |
9
+ 'quoted-printable' | 'base64' | ietf_token |
10
+ custom_x_token) >encoding_s %encoding_e;
11
+ content_transfer_encoding = CFWS? encoding CFWS? ";"? CFWS?;
12
+ }%%
@@ -0,0 +1,24 @@
1
+ %%{
2
+ # RFC 2045 Section 5.1: Content-Type Header Field
3
+ # https://tools.ietf.org/html/rfc2045#section-5.1
4
+ # Previously: https://tools.ietf.org/html/rfc1049#section-3
5
+ machine rfc2045_content_type;
6
+
7
+ include rfc5322_lexical_tokens "rfc5322_lexical_tokens.rl";
8
+
9
+ token = 0x21..0x27 | 0x2a..0x2b | 0x2c..0x2e | 0x30..0x39 | 0x41..0x5a | 0x5e..0x7e;
10
+ value = (quoted_string | (token -- '"' | 0x3d)+) >param_val_s %param_val_e;
11
+ attribute = (token+) >param_attr_s %param_attr_e;
12
+ parameter = CFWS? attribute "=" value CFWS?;
13
+
14
+ ietf_token = token+;
15
+ custom_x_token = 'x'i "-" token+;
16
+ extension_token = ietf_token | custom_x_token;
17
+ discrete_type = 'text'i | 'image'i | 'audio'i | 'video'i |
18
+ 'application'i | extension_token;
19
+ composite_type = 'message'i | 'multipart'i | extension_token;
20
+ iana_token = token+;
21
+ main_type = (discrete_type | composite_type) >main_type_s %main_type_e;
22
+ sub_type = (extension_token | iana_token) >sub_type_s %sub_type_e;
23
+ content_type = main_type "/" sub_type (((CFWS? ";"+) | CFWS) parameter CFWS?)*;
24
+ }%%
@@ -0,0 +1,15 @@
1
+ %%{
2
+ # RFC 2045 MIME
3
+ # https://tools.ietf.org/html/rfc2045
4
+ machine rfc2045_mime;
5
+
6
+ include rfc5322_lexical_tokens "rfc5322_lexical_tokens.rl";
7
+
8
+ # 4. MIME-Version Header Field
9
+ # https://tools.ietf.org/html/rfc2045#section-4
10
+ mime_version = CFWS?
11
+ (DIGIT+ >major_digits_s %major_digits_e)
12
+ comment? "." comment?
13
+ (DIGIT+ >minor_digits_s %minor_digits_e)
14
+ CFWS?;
15
+ }%%
@@ -0,0 +1,14 @@
1
+ %%{
2
+ # RFC 2183 The Content-Disposition Header Field
3
+ # https://tools.ietf.org/html/rfc2183#section-2
4
+ #
5
+ # TODO: recognize filename, size, creation date, etc.
6
+ machine rfc2183_content_disposition;
7
+
8
+ include rfc2045_content_type "rfc2045_content_type.rl";
9
+
10
+ disposition_type = 'inline'i | 'attachment'i | extension_token;
11
+ disposition_parm = parameter;
12
+ disposition = (disposition_type >disp_type_s %disp_type_e)
13
+ (";" disposition_parm)*;
14
+ }%%
@@ -0,0 +1,16 @@
1
+ %%{
2
+ # RFC 5234 B.1. Core Rules
3
+ # https://tools.ietf.org/html/rfc5234#appendix-B.1
4
+ machine rfc5234_abnf_core_rules;
5
+
6
+ LF = "\n";
7
+ CR = "\r";
8
+ CRLF = "\r\n";
9
+ SP = " ";
10
+ HTAB = "\t";
11
+ WSP = SP | HTAB;
12
+ DQUOTE = '"';
13
+ DIGIT = [0-9];
14
+ ALPHA = [a-zA-Z];
15
+ VCHAR = 0x21..0x7e;
16
+ }%%
@@ -0,0 +1,57 @@
1
+ %%{
2
+ # RFC 5322 Internet Message Format
3
+ # https://tools.ietf.org/html/rfc5322
4
+ #
5
+ # RFC 6854 Update to Internet Message Format to Allow Group Syntax in the "From:" and "Sender:" Header Fields
6
+ # https://tools.ietf.org/html/rfc6854
7
+ machine rfc5322;
8
+
9
+ include rfc5234_abnf_core_rules "rfc5234_abnf_core_rules.rl";
10
+
11
+ # 3.2. Lexical Tokens
12
+ include rfc5322_lexical_tokens "rfc5322_lexical_tokens.rl";
13
+
14
+ # 3.3. Date and Time Specification
15
+ include rfc5322_date_time "rfc5322_date_time.rl";
16
+
17
+ # 3.4. Address Specification
18
+ include rfc5322_address "rfc5322_address.rl";
19
+
20
+ # 3.5. Overall Message Syntax
21
+ #text = 0x01..0x09 | "\v" | "\f" | 0x0e..0x1f;
22
+ #obs_body = ((LF* CR* ((0x00 | text) LF* CR*)*) | CRLF)*
23
+ #body = ((text{,998} CRLF)* text{,998}) | obs_body;
24
+ #message = (fields | obs_fields) (CRLF body)?;
25
+
26
+
27
+ # 3.6. Field Definitions
28
+
29
+ # 3.6.4. Identification Fields
30
+ obs_id_left = local_part;
31
+ id_left = dot_atom_text | obs_id_left;
32
+ # id_right modifications to support multiple '@' in msg_id.
33
+ msg_id_atext = ALPHA | DIGIT | "!" | "#" | "$" | "%" | "&" | "'" | "*" |
34
+ "+" | "-" | "/" | "=" | "?" | "^" | "_" | "`" | "{" | "|" |
35
+ "}" | "~" | "@";
36
+ msg_id_dot_atom_text = (msg_id_atext+ "."?)+;
37
+ obs_id_right = domain;
38
+ no_fold_literal = "[" (dtext)* "]";
39
+ id_right = msg_id_dot_atom_text | no_fold_literal | obs_id_right;
40
+ msg_id = (CFWS)?
41
+ (("<" id_left "@" id_right ">") >msg_id_s %msg_id_e)
42
+ (CFWS)?;
43
+ message_ids = msg_id (CFWS? msg_id)*;
44
+
45
+
46
+ # 3.6.7 Trace Fields
47
+ # Added CFWS? to increase robustness (qmail likes to include a comment)
48
+ received_token = word | angle_addr | addr_spec_no_angle_brackets | domain;
49
+ received = ((CFWS? received_token*) >received_tokens_s %received_tokens_e)
50
+ ";" date_time;
51
+
52
+ # Envelope From
53
+ ctime_date = day_name " "+ month " "+ day " " time_of_day " " year;
54
+ null_sender = ('<>' ' '{0,1});
55
+ envelope_from = (addr_spec_no_angle_brackets | null_sender) >address_s %address_e " "
56
+ (ctime_date >ctime_date_s %ctime_date_e);
57
+ }%%
@@ -0,0 +1,70 @@
1
+ %%{
2
+ # RFC 5322 Internet Message Format
3
+ # Section 3.4. Address Specification
4
+ # https://tools.ietf.org/html/rfc5322#section-3.4
5
+ machine rfc5322_address;
6
+
7
+ include rfc5234_abnf_core_rules "rfc5234_abnf_core_rules.rl";
8
+ include rfc5322_lexical_tokens "rfc5322_lexical_tokens.rl";
9
+
10
+ # local_part:
11
+ domain_text = (DQUOTE (FWS? qcontent)+ FWS? DQUOTE) | atext+;
12
+ local_dot_atom_text = ("."* domain_text "."*)+;
13
+ local_dot_atom = CFWS?
14
+ (local_dot_atom_text >local_dot_atom_s %local_dot_atom_pre_comment_e)
15
+ CFWS?;
16
+ obs_local_part = word ("." word)*;
17
+ local_part = (local_dot_atom >local_dot_atom_s %local_dot_atom_e |
18
+ (quoted_string %local_quoted_string_e) |
19
+ obs_local_part);
20
+
21
+ # Treetop parser behavior was to ignore addresses missing '@' inside of angle
22
+ # brackets. This construction preserves that behavior.
23
+ local_part_no_capture = (local_dot_atom | quoted_string | obs_local_part);
24
+
25
+ # domain:
26
+ domain_dot_atom_text = "."* domain_text ("."* domain_text)*;
27
+ obs_dtext = obs_NO_WS_CTL | quoted_pair;
28
+ dtext = 0x21..0x5a | 0x5e..0x7e | obs_dtext;
29
+ domain_dot_atom = CFWS? domain_dot_atom_text (CFWS? >(comment_after_address,1));
30
+ domain_literal = CFWS? "[" (FWS? dtext)* FWS? "]" CFWS?;
31
+ obs_domain = atom ("." atom)*;
32
+ domain = (domain_dot_atom | domain_literal | obs_domain) >domain_s %domain_e;
33
+
34
+ # 3.4.1. Addr-Spec Specification
35
+
36
+ # The %(end_addr,N) priority resolves uncertainty when whitespace
37
+ # after an addr_spec could cause it to be interpreted as a
38
+ # display name: "bar@example.com ,..."
39
+
40
+ addr_spec_in_angle_brackets =
41
+ (local_part "@" domain) %(end_addr,1) |
42
+ local_part_no_capture %(end_addr,0);
43
+
44
+ addr_spec_no_angle_brackets =
45
+ (local_part "@" domain) %(end_addr,1) |
46
+ local_part %(end_addr,0);
47
+
48
+ # angle_addr:
49
+ obs_domain_list = (CFWS | ",")* "@" domain ("," CFWS? ("@" domain)?)*;
50
+ obs_route = (obs_domain_list ":") >obs_domain_list_s %obs_domain_list_e;
51
+ obs_angle_addr = CFWS? "<" obs_route? addr_spec_in_angle_brackets ">" CFWS?;
52
+
53
+ angle_addr = CFWS? ("<" >angle_addr_s) addr_spec_in_angle_brackets ">" CFWS? |
54
+ obs_angle_addr;
55
+
56
+ # 3.4. Address Specification
57
+ display_name = phrase;
58
+ name_addr = display_name? %(end_addr,2) angle_addr;
59
+ mailbox = (name_addr | addr_spec_no_angle_brackets) >address_s %address_e;
60
+ obs_mbox_list = (CFWS? ",")* mailbox ("," (mailbox | CFWS)?)*;
61
+ mailbox_list = (mailbox (("," | ";") mailbox)*) | obs_mbox_list;
62
+ obs_group_list = (CFWS? ",")+ CFWS?;
63
+ group_list = mailbox_list | CFWS | obs_group_list;
64
+ group = (display_name >group_name_s %group_name_e) ":"
65
+ (group_list?) ";" CFWS?;
66
+ address = group | mailbox;
67
+ #obs_addr_list = (CFWS? ",")* address ("," (address | CFWS)?)*;
68
+ address_lists = address? %(comment_after_address,0)
69
+ (FWS* ("," | ";") FWS* address?)*;
70
+ }%%
@@ -1,6 +1,10 @@
1
1
  %%{
2
+ # RFC 5322 Internet Message Format
3
+ # Section 3.3. Date and Time Specification
4
+ # https://tools.ietf.org/html/rfc5322#section-3.3
5
+ machine rfc5322_date_time;
2
6
 
3
- machine date_time;
7
+ include rfc5322_lexical_tokens "rfc5322_lexical_tokens.rl";
4
8
 
5
9
  # day_of_week
6
10
  day_name = "Mon" | "Tue" | "Wed" | "Thu" | "Fri" | "Sat" | "Sun";
@@ -27,4 +31,6 @@
27
31
  zone = FWS ((("+" | "-") DIGIT DIGIT DIGIT DIGIT) | obs_zone);
28
32
  time = time_of_day zone;
29
33
 
34
+ date_time = (day_of_week ",")?
35
+ (date >date_s %date_e) <: (time >time_s %time_e) CFWS?;
30
36
  }%%
@@ -0,0 +1,56 @@
1
+ %%{
2
+ # RFC 5322 Internet Message Format
3
+ # Section 3.2. Lexical Tokens
4
+ # https://tools.ietf.org/html/rfc5322#section-3.2
5
+ machine rfc5322_lexical_tokens;
6
+
7
+ include rfc5234_abnf_core_rules "rfc5234_abnf_core_rules.rl";
8
+
9
+ # 3.2.1. Quoted characters
10
+ obs_NO_WS_CTL = 0x01..0x08 | "\v" | "\f" | 0x0e..0x1f | 0x7f;
11
+ obs_qp = "\\" (0x00 | obs_NO_WS_CTL | LF | CR);
12
+ quoted_pair = ("\\" (VCHAR | WSP)) | obs_qp;
13
+
14
+ # 3.2.2. Folding White Space and Comments
15
+ obs_FWS = (CRLF? WSP)+;
16
+ FWS = (WSP* CRLF WSP+) | (CRLF WSP+) | obs_FWS;
17
+
18
+ obs_ctext = obs_NO_WS_CTL;
19
+ ctext = 0x21..0x27 | 0x2a..0x5b | 0x5d..0x7e | obs_ctext;
20
+
21
+ # Recursive comments
22
+ action comment_begin { fcall comment_tail; }
23
+ action comment_exit { fret; }
24
+ ccontent = ctext | quoted_pair | "(" @comment_begin;
25
+ comment_tail := ((FWS? ccontent)* >comment_s) FWS? ")" @comment_exit;
26
+ comment = "(" @comment_begin %comment_e;
27
+ CFWS = ((FWS? comment)+ FWS?) | FWS;
28
+
29
+ # 3.2.3. Atom
30
+ atext = ALPHA | DIGIT | "!" | "#" | "$" | "%" | "&" |
31
+ "'" | "*" | "+" | "-" | "/" | "=" | "?" | "^" |
32
+ "_" | "`" | "{" | "|" | "}" | "~";
33
+ atom = CFWS? atext+ CFWS?;
34
+ dot_atom_text = atext ("." atext)*;
35
+ dot_atom = CFWS? dot_atom_text CFWS?;
36
+
37
+ # 3.2.4. Quoted Strings
38
+ obs_qtext = obs_NO_WS_CTL;
39
+ qtext = 0x21 | 0x23..0x5b | 0x5d..0x7e | obs_qtext;
40
+
41
+ qcontent = qtext | quoted_pair;
42
+ quoted_string = CFWS?
43
+ (DQUOTE
44
+ (((FWS? qcontent)* FWS?) >qstr_s %qstr_e)
45
+ DQUOTE)
46
+ CFWS?;
47
+
48
+ # 3.2.5. Miscellaneous Tokens
49
+ word = atom | quoted_string;
50
+
51
+ obs_phrase = (word | "." | "@")+;
52
+ phrase = (obs_phrase | word+) >phrase_s %phrase_e;
53
+
54
+ # Not part of RFC, used for keywords per 3.6.5 Information Fields
55
+ phrase_lists = phrase ("," FWS* phrase)*;
56
+ }%%
data/lib/mail/part.rb CHANGED
@@ -21,7 +21,7 @@ module Mail
21
21
 
22
22
  def inline_content_id
23
23
  # TODO: Deprecated in 2.2.2 - Remove in 2.3
24
- STDERR.puts("Part#inline_content_id is deprecated, please call Part#cid instead")
24
+ $stderr.puts("Part#inline_content_id is deprecated, please call Part#cid instead")
25
25
  cid
26
26
  end
27
27
 
@@ -55,7 +55,7 @@ module Mail
55
55
  # OK, 10000 is arbitrary... if anyone actually wants to explicitly sort 10000 parts of a
56
56
  # single email message... please show me a use case and I'll put more work into this method,
57
57
  # in the meantime, it works :)
58
- [get_order_value(a, order), i += 1]
58
+ get_order_value(a, order) << (i += 1)
59
59
  end
60
60
  @parts.clear
61
61
  sorted.each { |p| @parts << p }
@@ -64,11 +64,10 @@ module Mail
64
64
  private
65
65
 
66
66
  def get_order_value(part, order)
67
- if part.respond_to?(:content_type) && !part[:content_type].nil?
68
- order.index(part[:content_type].string.downcase) || 10000
69
- else
70
- 10000
71
- end
67
+ is_attachment = part.respond_to?(:attachment?) && part.attachment?
68
+ has_content_type = part.respond_to?(:content_type) && !part[:content_type].nil?
69
+
70
+ [is_attachment ? 1 : 0, (has_content_type ? order.index(part[:content_type].string.downcase) : nil) || 10000]
72
71
  end
73
72
 
74
73
  end
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
  # frozen_string_literal: true
3
+ require 'mail/constants'
4
+
3
5
  module Mail
4
6
  module Utilities
5
7
 
@@ -77,6 +79,7 @@ module Mail
77
79
  str
78
80
  end
79
81
  end
82
+ module_function :unquote
80
83
 
81
84
  # Removes any \-escaping.
82
85
  #
@@ -192,7 +195,7 @@ module Mail
192
195
  # Example:
193
196
  #
194
197
  # string = :resent_from_field
195
- # dasherize ( string ) #=> 'resent_from_field'
198
+ # dasherize( string ) #=> 'resent-from-field'
196
199
  def dasherize( str )
197
200
  str.to_s.tr(UNDERSCORE, HYPHEN)
198
201
  end
@@ -288,6 +291,5 @@ module Mail
288
291
  value.respond_to?(:empty?) ? value.empty? : !value
289
292
  end
290
293
  end
291
-
292
294
  end
293
295
  end
data/lib/mail/version.rb CHANGED
@@ -3,9 +3,9 @@ module Mail
3
3
  module VERSION
4
4
 
5
5
  MAJOR = 2
6
- MINOR = 6
7
- PATCH = 6
8
- BUILD = nil
6
+ MINOR = 7
7
+ PATCH = 0
8
+ BUILD = 'rc1'
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
11
11