From 596f06f7cbbd47b2c80b2d07e45fe41992d28d6b Mon Sep 17 00:00:00 2001 From: Hartley McGuire Date: Fri, 23 Dec 2022 15:21:02 -0500 Subject: [PATCH 1/2] rake ragel The formatting differences are likely due to using a newer version of rufo --- lib/mail/parsers/address_lists_parser.rb | 9 ++++---- .../parsers/content_disposition_parser.rb | 23 +++++++++---------- lib/mail/parsers/content_location_parser.rb | 9 ++++---- .../content_transfer_encoding_parser.rb | 9 ++++---- lib/mail/parsers/content_type_parser.rb | 23 +++++++++---------- lib/mail/parsers/date_time_parser.rb | 9 ++++---- lib/mail/parsers/envelope_from_parser.rb | 9 ++++---- lib/mail/parsers/message_ids_parser.rb | 9 ++++---- lib/mail/parsers/mime_version_parser.rb | 9 ++++---- lib/mail/parsers/phrase_lists_parser.rb | 9 ++++---- lib/mail/parsers/received_parser.rb | 9 ++++---- 11 files changed, 58 insertions(+), 69 deletions(-) diff --git a/lib/mail/parsers/address_lists_parser.rb b/lib/mail/parsers/address_lists_parser.rb index f905e7313..1665333da 100644 --- a/lib/mail/parsers/address_lists_parser.rb +++ b/lib/mail/parsers/address_lists_parser.rb @@ -1,4 +1,3 @@ - # frozen_string_literal: true require "mail/utilities" require "mail/parser_tools" @@ -32011,10 +32010,10 @@ def self.parse(data) _trans = if (_slen > 0 && _trans_keys[_keys] <= _wide && _wide <= _trans_keys[_keys + 1]) - _indicies[_inds + _wide - _trans_keys[_keys]] - else - _indicies[_inds + _slen] - end + _indicies[_inds + _wide - _trans_keys[_keys]] + else + _indicies[_inds + _slen] + end cs = _trans_targs[_trans] if _trans_actions[_trans] != 0 case _trans_actions[_trans] diff --git a/lib/mail/parsers/content_disposition_parser.rb b/lib/mail/parsers/content_disposition_parser.rb index c92fbda29..e95e640b0 100644 --- a/lib/mail/parsers/content_disposition_parser.rb +++ b/lib/mail/parsers/content_disposition_parser.rb @@ -1,4 +1,3 @@ - # frozen_string_literal: true require "mail/utilities" require "mail/parser_tools" @@ -610,10 +609,10 @@ def self.parse(data) _trans = if (_slen > 0 && _trans_keys[_keys] <= _wide && _wide <= _trans_keys[_keys + 1]) - _indicies[_inds + _wide - _trans_keys[_keys]] - else - _indicies[_inds + _slen] - end + _indicies[_inds + _wide - _trans_keys[_keys]] + else + _indicies[_inds + _slen] + end cs = _trans_targs[_trans] if _trans_actions[_trans] != 0 case _trans_actions[_trans] @@ -654,7 +653,7 @@ def self.parse(data) # Use quoted string value if one exists, otherwise use parameter value value = qstr || chars(data, param_val_s, p - 1) - content_disposition.parameters << {param_attr => value} + content_disposition.parameters << { param_attr => value } param_attr = nil qstr = nil end @@ -712,7 +711,7 @@ def self.parse(data) # Use quoted string value if one exists, otherwise use parameter value value = qstr || chars(data, param_val_s, p - 1) - content_disposition.parameters << {param_attr => value} + content_disposition.parameters << { param_attr => value } param_attr = nil qstr = nil end @@ -742,7 +741,7 @@ def self.parse(data) # Use quoted string value if one exists, otherwise use parameter value value = qstr || chars(data, param_val_s, p - 1) - content_disposition.parameters << {param_attr => value} + content_disposition.parameters << { param_attr => value } param_attr = nil qstr = nil end @@ -799,7 +798,7 @@ def self.parse(data) # Use quoted string value if one exists, otherwise use parameter value value = qstr || chars(data, param_val_s, p - 1) - content_disposition.parameters << {param_attr => value} + content_disposition.parameters << { param_attr => value } param_attr = nil qstr = nil end @@ -823,7 +822,7 @@ def self.parse(data) # Use quoted string value if one exists, otherwise use parameter value value = qstr || chars(data, param_val_s, p - 1) - content_disposition.parameters << {param_attr => value} + content_disposition.parameters << { param_attr => value } param_attr = nil qstr = nil end @@ -857,7 +856,7 @@ def self.parse(data) # Use quoted string value if one exists, otherwise use parameter value value = qstr || chars(data, param_val_s, p - 1) - content_disposition.parameters << {param_attr => value} + content_disposition.parameters << { param_attr => value } param_attr = nil qstr = nil end @@ -875,7 +874,7 @@ def self.parse(data) # Use quoted string value if one exists, otherwise use parameter value value = qstr || chars(data, param_val_s, p - 1) - content_disposition.parameters << {param_attr => value} + content_disposition.parameters << { param_attr => value } param_attr = nil qstr = nil end diff --git a/lib/mail/parsers/content_location_parser.rb b/lib/mail/parsers/content_location_parser.rb index e44824411..8cc4b15f6 100644 --- a/lib/mail/parsers/content_location_parser.rb +++ b/lib/mail/parsers/content_location_parser.rb @@ -1,4 +1,3 @@ - # frozen_string_literal: true require "mail/utilities" require "mail/parser_tools" @@ -631,10 +630,10 @@ def self.parse(data) _trans = if (_slen > 0 && _trans_keys[_keys] <= _wide && _wide <= _trans_keys[_keys + 1]) - _indicies[_inds + _wide - _trans_keys[_keys]] - else - _indicies[_inds + _slen] - end + _indicies[_inds + _wide - _trans_keys[_keys]] + else + _indicies[_inds + _slen] + end cs = _trans_targs[_trans] if _trans_actions[_trans] != 0 case _trans_actions[_trans] diff --git a/lib/mail/parsers/content_transfer_encoding_parser.rb b/lib/mail/parsers/content_transfer_encoding_parser.rb index 2c8b535e1..bcda478f4 100644 --- a/lib/mail/parsers/content_transfer_encoding_parser.rb +++ b/lib/mail/parsers/content_transfer_encoding_parser.rb @@ -1,4 +1,3 @@ - # frozen_string_literal: true require "mail/utilities" require "mail/parser_tools" @@ -382,10 +381,10 @@ def self.parse(data) _trans = if (_slen > 0 && _trans_keys[_keys] <= _wide && _wide <= _trans_keys[_keys + 1]) - _indicies[_inds + _wide - _trans_keys[_keys]] - else - _indicies[_inds + _slen] - end + _indicies[_inds + _wide - _trans_keys[_keys]] + else + _indicies[_inds + _slen] + end cs = _trans_targs[_trans] if _trans_actions[_trans] != 0 case _trans_actions[_trans] diff --git a/lib/mail/parsers/content_type_parser.rb b/lib/mail/parsers/content_type_parser.rb index 6716bd7a9..75a81e324 100644 --- a/lib/mail/parsers/content_type_parser.rb +++ b/lib/mail/parsers/content_type_parser.rb @@ -1,4 +1,3 @@ - # frozen_string_literal: true require "mail/utilities" require "mail/parser_tools" @@ -736,10 +735,10 @@ def self.parse(data) _trans = if (_slen > 0 && _trans_keys[_keys] <= _wide && _wide <= _trans_keys[_keys + 1]) - _indicies[_inds + _wide - _trans_keys[_keys]] - else - _indicies[_inds + _slen] - end + _indicies[_inds + _wide - _trans_keys[_keys]] + else + _indicies[_inds + _slen] + end cs = _trans_targs[_trans] if _trans_actions[_trans] != 0 case _trans_actions[_trans] @@ -788,7 +787,7 @@ def self.parse(data) # Use quoted s value if one exists, otherwise use parameter value value = qstr || chars(data, param_val_s, p - 1) - content_type.parameters << {param_attr => value} + content_type.parameters << { param_attr => value } param_attr = nil qstr = nil end @@ -859,7 +858,7 @@ def self.parse(data) # Use quoted s value if one exists, otherwise use parameter value value = qstr || chars(data, param_val_s, p - 1) - content_type.parameters << {param_attr => value} + content_type.parameters << { param_attr => value } param_attr = nil qstr = nil end @@ -889,7 +888,7 @@ def self.parse(data) # Use quoted s value if one exists, otherwise use parameter value value = qstr || chars(data, param_val_s, p - 1) - content_type.parameters << {param_attr => value} + content_type.parameters << { param_attr => value } param_attr = nil qstr = nil end @@ -946,7 +945,7 @@ def self.parse(data) # Use quoted s value if one exists, otherwise use parameter value value = qstr || chars(data, param_val_s, p - 1) - content_type.parameters << {param_attr => value} + content_type.parameters << { param_attr => value } param_attr = nil qstr = nil end @@ -970,7 +969,7 @@ def self.parse(data) # Use quoted s value if one exists, otherwise use parameter value value = qstr || chars(data, param_val_s, p - 1) - content_type.parameters << {param_attr => value} + content_type.parameters << { param_attr => value } param_attr = nil qstr = nil end @@ -1004,7 +1003,7 @@ def self.parse(data) # Use quoted s value if one exists, otherwise use parameter value value = qstr || chars(data, param_val_s, p - 1) - content_type.parameters << {param_attr => value} + content_type.parameters << { param_attr => value } param_attr = nil qstr = nil end @@ -1022,7 +1021,7 @@ def self.parse(data) # Use quoted s value if one exists, otherwise use parameter value value = qstr || chars(data, param_val_s, p - 1) - content_type.parameters << {param_attr => value} + content_type.parameters << { param_attr => value } param_attr = nil qstr = nil end diff --git a/lib/mail/parsers/date_time_parser.rb b/lib/mail/parsers/date_time_parser.rb index 3696e57cd..8afd91d0c 100644 --- a/lib/mail/parsers/date_time_parser.rb +++ b/lib/mail/parsers/date_time_parser.rb @@ -1,4 +1,3 @@ - # frozen_string_literal: true require "mail/utilities" require "mail/parser_tools" @@ -715,10 +714,10 @@ def self.parse(data) _trans = if (_slen > 0 && _trans_keys[_keys] <= _wide && _wide <= _trans_keys[_keys + 1]) - _indicies[_inds + _wide - _trans_keys[_keys]] - else - _indicies[_inds + _slen] - end + _indicies[_inds + _wide - _trans_keys[_keys]] + else + _indicies[_inds + _slen] + end cs = _trans_targs[_trans] if _trans_actions[_trans] != 0 case _trans_actions[_trans] diff --git a/lib/mail/parsers/envelope_from_parser.rb b/lib/mail/parsers/envelope_from_parser.rb index b450f0c70..fa224c431 100644 --- a/lib/mail/parsers/envelope_from_parser.rb +++ b/lib/mail/parsers/envelope_from_parser.rb @@ -1,4 +1,3 @@ - # frozen_string_literal: true require "mail/utilities" require "mail/parser_tools" @@ -3265,10 +3264,10 @@ def self.parse(data) _trans = if (_slen > 0 && _trans_keys[_keys] <= _wide && _wide <= _trans_keys[_keys + 1]) - _indicies[_inds + _wide - _trans_keys[_keys]] - else - _indicies[_inds + _slen] - end + _indicies[_inds + _wide - _trans_keys[_keys]] + else + _indicies[_inds + _slen] + end cs = _trans_targs[_trans] if _trans_actions[_trans] != 0 case _trans_actions[_trans] diff --git a/lib/mail/parsers/message_ids_parser.rb b/lib/mail/parsers/message_ids_parser.rb index 35e5a64df..f265f9196 100644 --- a/lib/mail/parsers/message_ids_parser.rb +++ b/lib/mail/parsers/message_ids_parser.rb @@ -1,4 +1,3 @@ - # frozen_string_literal: true require "mail/utilities" require "mail/parser_tools" @@ -4872,10 +4871,10 @@ def self.parse(data) _trans = if (_slen > 0 && _trans_keys[_keys] <= _wide && _wide <= _trans_keys[_keys + 1]) - _indicies[_inds + _wide - _trans_keys[_keys]] - else - _indicies[_inds + _slen] - end + _indicies[_inds + _wide - _trans_keys[_keys]] + else + _indicies[_inds + _slen] + end cs = _trans_targs[_trans] if _trans_actions[_trans] != 0 case _trans_actions[_trans] diff --git a/lib/mail/parsers/mime_version_parser.rb b/lib/mail/parsers/mime_version_parser.rb index f7a1bd63a..9c915dd62 100644 --- a/lib/mail/parsers/mime_version_parser.rb +++ b/lib/mail/parsers/mime_version_parser.rb @@ -1,4 +1,3 @@ - # frozen_string_literal: true require "mail/utilities" require "mail/parser_tools" @@ -346,10 +345,10 @@ def self.parse(data) _trans = if (_slen > 0 && _trans_keys[_keys] <= _wide && _wide <= _trans_keys[_keys + 1]) - _indicies[_inds + _wide - _trans_keys[_keys]] - else - _indicies[_inds + _slen] - end + _indicies[_inds + _wide - _trans_keys[_keys]] + else + _indicies[_inds + _slen] + end cs = _trans_targs[_trans] if _trans_actions[_trans] != 0 case _trans_actions[_trans] diff --git a/lib/mail/parsers/phrase_lists_parser.rb b/lib/mail/parsers/phrase_lists_parser.rb index 1d70d7086..0f66d3be5 100644 --- a/lib/mail/parsers/phrase_lists_parser.rb +++ b/lib/mail/parsers/phrase_lists_parser.rb @@ -1,4 +1,3 @@ - # frozen_string_literal: true require "mail/utilities" require "mail/parser_tools" @@ -726,10 +725,10 @@ def self.parse(data) _trans = if (_slen > 0 && _trans_keys[_keys] <= _wide && _wide <= _trans_keys[_keys + 1]) - _indicies[_inds + _wide - _trans_keys[_keys]] - else - _indicies[_inds + _slen] - end + _indicies[_inds + _wide - _trans_keys[_keys]] + else + _indicies[_inds + _slen] + end cs = _trans_targs[_trans] if _trans_actions[_trans] != 0 case _trans_actions[_trans] diff --git a/lib/mail/parsers/received_parser.rb b/lib/mail/parsers/received_parser.rb index b8e0ca425..b24c2f5b7 100644 --- a/lib/mail/parsers/received_parser.rb +++ b/lib/mail/parsers/received_parser.rb @@ -1,4 +1,3 @@ - # frozen_string_literal: true require "mail/utilities" require "mail/parser_tools" @@ -7538,10 +7537,10 @@ def self.parse(data) _trans = if (_slen > 0 && _trans_keys[_keys] <= _wide && _wide <= _trans_keys[_keys + 1]) - _indicies[_inds + _wide - _trans_keys[_keys]] - else - _indicies[_inds + _slen] - end + _indicies[_inds + _wide - _trans_keys[_keys]] + else + _indicies[_inds + _slen] + end cs = _trans_targs[_trans] if _trans_actions[_trans] != 0 case _trans_actions[_trans] From 8dd1655dc4628e34d9d654a1526bac7cd9513252 Mon Sep 17 00:00:00 2001 From: Hartley McGuire Date: Fri, 23 Dec 2022 15:47:35 -0500 Subject: [PATCH 2/2] Fix all 'assigned but unused variable' warnings - The variables in content_location_parser appear to have been copied from content_disposition_parser but are unused - Ragel seems to always generate a useless testEof variable. The `if false` trick is also used in whitequark/parser@21581a2 to suppress the warning. As mentioned in the parser commit, `if false` will not actually generate instructions and so it has no runtime cost. Co-authored-by: Guilherme Quirino --- lib/mail/parsers/address_lists_parser.rb | 4 ++++ lib/mail/parsers/address_lists_parser.rl | 4 ++++ lib/mail/parsers/content_disposition_parser.rb | 4 ++++ lib/mail/parsers/content_disposition_parser.rl | 4 ++++ lib/mail/parsers/content_location_parser.rb | 6 +++++- lib/mail/parsers/content_location_parser.rl | 6 +++++- lib/mail/parsers/content_transfer_encoding_parser.rb | 4 ++++ lib/mail/parsers/content_transfer_encoding_parser.rl | 4 ++++ lib/mail/parsers/content_type_parser.rb | 4 ++++ lib/mail/parsers/content_type_parser.rl | 4 ++++ lib/mail/parsers/date_time_parser.rb | 4 ++++ lib/mail/parsers/date_time_parser.rl | 4 ++++ lib/mail/parsers/envelope_from_parser.rb | 4 ++++ lib/mail/parsers/envelope_from_parser.rl | 4 ++++ lib/mail/parsers/message_ids_parser.rb | 4 ++++ lib/mail/parsers/message_ids_parser.rl | 4 ++++ lib/mail/parsers/mime_version_parser.rb | 4 ++++ lib/mail/parsers/mime_version_parser.rl | 4 ++++ lib/mail/parsers/phrase_lists_parser.rb | 4 ++++ lib/mail/parsers/phrase_lists_parser.rl | 4 ++++ lib/mail/parsers/received_parser.rb | 4 ++++ lib/mail/parsers/received_parser.rl | 4 ++++ spec/mail/network/delivery_methods/smtp_connection_spec.rb | 2 -- 23 files changed, 90 insertions(+), 4 deletions(-) diff --git a/lib/mail/parsers/address_lists_parser.rb b/lib/mail/parsers/address_lists_parser.rb index 1665333da..c49340fc5 100644 --- a/lib/mail/parsers/address_lists_parser.rb +++ b/lib/mail/parsers/address_lists_parser.rb @@ -33228,6 +33228,10 @@ def self.parse(data) end end + if false + testEof + end + if p != eof || cs < 2461 raise Mail::Field::IncompleteParseError.new(Mail::AddressList, data, p) end diff --git a/lib/mail/parsers/address_lists_parser.rl b/lib/mail/parsers/address_lists_parser.rl index b619947f1..6d44ae222 100644 --- a/lib/mail/parsers/address_lists_parser.rl +++ b/lib/mail/parsers/address_lists_parser.rl @@ -165,6 +165,10 @@ module Mail::Parsers %%write init; %%write exec; + if false + testEof + end + if p != eof || cs < %%{ write first_final; }%% raise Mail::Field::IncompleteParseError.new(Mail::AddressList, data, p) end diff --git a/lib/mail/parsers/content_disposition_parser.rb b/lib/mail/parsers/content_disposition_parser.rb index e95e640b0..e2f81ea6b 100644 --- a/lib/mail/parsers/content_disposition_parser.rb +++ b/lib/mail/parsers/content_disposition_parser.rb @@ -887,6 +887,10 @@ def self.parse(data) end end + if false + testEof + end + if p != eof || cs < 40 raise Mail::Field::IncompleteParseError.new(Mail::ContentDispositionElement, data, p) end diff --git a/lib/mail/parsers/content_disposition_parser.rl b/lib/mail/parsers/content_disposition_parser.rl index 431893d50..c53c9a576 100644 --- a/lib/mail/parsers/content_disposition_parser.rl +++ b/lib/mail/parsers/content_disposition_parser.rl @@ -75,6 +75,10 @@ module Mail::Parsers %%write init; %%write exec; + if false + testEof + end + if p != eof || cs < %%{ write first_final; }%% raise Mail::Field::IncompleteParseError.new(Mail::ContentDispositionElement, data, p) end diff --git a/lib/mail/parsers/content_location_parser.rb b/lib/mail/parsers/content_location_parser.rb index 8cc4b15f6..f10a43850 100644 --- a/lib/mail/parsers/content_location_parser.rb +++ b/lib/mail/parsers/content_location_parser.rb @@ -588,7 +588,7 @@ def self.parse(data) return content_location if Mail::Utilities.blank?(data) # Parser state - disp_type_s = param_attr_s = param_attr = qstr_s = qstr = param_val_s = nil + qstr_s = qstr = param_val_s = nil # 5.1 Variables Used by Ragel p = 0 @@ -808,6 +808,10 @@ def self.parse(data) end end + if false + testEof + end + if p != eof || cs < 32 raise Mail::Field::IncompleteParseError.new(Mail::ContentLocationElement, data, p) end diff --git a/lib/mail/parsers/content_location_parser.rl b/lib/mail/parsers/content_location_parser.rl index 4fb035472..816a18345 100644 --- a/lib/mail/parsers/content_location_parser.rl +++ b/lib/mail/parsers/content_location_parser.rl @@ -54,7 +54,7 @@ module Mail::Parsers return content_location if Mail::Utilities.blank?(data) # Parser state - disp_type_s = param_attr_s = param_attr = qstr_s = qstr = param_val_s = nil + qstr_s = qstr = param_val_s = nil # 5.1 Variables Used by Ragel p = 0 @@ -64,6 +64,10 @@ module Mail::Parsers %%write init; %%write exec; + if false + testEof + end + if p != eof || cs < %%{ write first_final; }%% raise Mail::Field::IncompleteParseError.new(Mail::ContentLocationElement, data, p) end diff --git a/lib/mail/parsers/content_transfer_encoding_parser.rb b/lib/mail/parsers/content_transfer_encoding_parser.rb index bcda478f4..18c149436 100644 --- a/lib/mail/parsers/content_transfer_encoding_parser.rb +++ b/lib/mail/parsers/content_transfer_encoding_parser.rb @@ -508,6 +508,10 @@ def self.parse(data) end end + if false + testEof + end + if p != eof || cs < 21 raise Mail::Field::IncompleteParseError.new(Mail::ContentTransferEncodingElement, data, p) end diff --git a/lib/mail/parsers/content_transfer_encoding_parser.rl b/lib/mail/parsers/content_transfer_encoding_parser.rl index f20dd0378..d13143665 100644 --- a/lib/mail/parsers/content_transfer_encoding_parser.rl +++ b/lib/mail/parsers/content_transfer_encoding_parser.rl @@ -57,6 +57,10 @@ module Mail::Parsers %%write init; %%write exec; + if false + testEof + end + if p != eof || cs < %%{ write first_final; }%% raise Mail::Field::IncompleteParseError.new(Mail::ContentTransferEncodingElement, data, p) end diff --git a/lib/mail/parsers/content_type_parser.rb b/lib/mail/parsers/content_type_parser.rb index 75a81e324..18a1361fb 100644 --- a/lib/mail/parsers/content_type_parser.rb +++ b/lib/mail/parsers/content_type_parser.rb @@ -1034,6 +1034,10 @@ def self.parse(data) end end + if false + testEof + end + if p != eof || cs < 47 raise Mail::Field::IncompleteParseError.new(Mail::ContentTypeElement, data, p) end diff --git a/lib/mail/parsers/content_type_parser.rl b/lib/mail/parsers/content_type_parser.rl index 724e43df2..222b7c86c 100644 --- a/lib/mail/parsers/content_type_parser.rl +++ b/lib/mail/parsers/content_type_parser.rl @@ -76,6 +76,10 @@ module Mail::Parsers %%write init; %%write exec; + if false + testEof + end + if p != eof || cs < %%{ write first_final; }%% raise Mail::Field::IncompleteParseError.new(Mail::ContentTypeElement, data, p) end diff --git a/lib/mail/parsers/date_time_parser.rb b/lib/mail/parsers/date_time_parser.rb index 8afd91d0c..ffe8ecc70 100644 --- a/lib/mail/parsers/date_time_parser.rb +++ b/lib/mail/parsers/date_time_parser.rb @@ -877,6 +877,10 @@ def self.parse(data) end end + if false + testEof + end + if p != eof || cs < 103 raise Mail::Field::IncompleteParseError.new(Mail::DateTimeElement, data, p) end diff --git a/lib/mail/parsers/date_time_parser.rl b/lib/mail/parsers/date_time_parser.rl index 44b80c6e5..afdef0088 100644 --- a/lib/mail/parsers/date_time_parser.rl +++ b/lib/mail/parsers/date_time_parser.rl @@ -55,6 +55,10 @@ module Mail::Parsers %%write init; %%write exec; + if false + testEof + end + if p != eof || cs < %%{ write first_final; }%% raise Mail::Field::IncompleteParseError.new(Mail::DateTimeElement, data, p) end diff --git a/lib/mail/parsers/envelope_from_parser.rb b/lib/mail/parsers/envelope_from_parser.rb index fa224c431..e121eae78 100644 --- a/lib/mail/parsers/envelope_from_parser.rb +++ b/lib/mail/parsers/envelope_from_parser.rb @@ -3661,6 +3661,10 @@ def self.parse(data) end end + if false + testEof + end + if p != eof || cs < 257 raise Mail::Field::IncompleteParseError.new(Mail::EnvelopeFromElement, data, p) end diff --git a/lib/mail/parsers/envelope_from_parser.rl b/lib/mail/parsers/envelope_from_parser.rl index d88eb0142..4362db8db 100644 --- a/lib/mail/parsers/envelope_from_parser.rl +++ b/lib/mail/parsers/envelope_from_parser.rl @@ -75,6 +75,10 @@ module Mail::Parsers %%write init; %%write exec; + if false + testEof + end + if p != eof || cs < %%{ write first_final; }%% raise Mail::Field::IncompleteParseError.new(Mail::EnvelopeFromElement, data, p) end diff --git a/lib/mail/parsers/message_ids_parser.rb b/lib/mail/parsers/message_ids_parser.rb index f265f9196..aa2dbf6d3 100644 --- a/lib/mail/parsers/message_ids_parser.rb +++ b/lib/mail/parsers/message_ids_parser.rb @@ -5147,6 +5147,10 @@ def self.parse(data) end end + if false + testEof + end + if p != eof || cs < 318 raise Mail::Field::IncompleteParseError.new(Mail::MessageIdsElement, data, p) end diff --git a/lib/mail/parsers/message_ids_parser.rl b/lib/mail/parsers/message_ids_parser.rl index 1e3432294..299636b65 100644 --- a/lib/mail/parsers/message_ids_parser.rl +++ b/lib/mail/parsers/message_ids_parser.rl @@ -79,6 +79,10 @@ module Mail::Parsers %%write init; %%write exec; + if false + testEof + end + if p != eof || cs < %%{ write first_final; }%% raise Mail::Field::IncompleteParseError.new(Mail::MessageIdsElement, data, p) end diff --git a/lib/mail/parsers/mime_version_parser.rb b/lib/mail/parsers/mime_version_parser.rb index 9c915dd62..42dcb44f4 100644 --- a/lib/mail/parsers/mime_version_parser.rb +++ b/lib/mail/parsers/mime_version_parser.rb @@ -499,6 +499,10 @@ def self.parse(data) end end + if false + testEof + end + if p != eof || cs < 23 raise Mail::Field::IncompleteParseError.new(Mail::MimeVersionElement, data, p) end diff --git a/lib/mail/parsers/mime_version_parser.rl b/lib/mail/parsers/mime_version_parser.rl index c69d3f009..eb5a33ce9 100644 --- a/lib/mail/parsers/mime_version_parser.rl +++ b/lib/mail/parsers/mime_version_parser.rl @@ -54,6 +54,10 @@ module Mail::Parsers %%write init; %%write exec; + if false + testEof + end + if p != eof || cs < %%{ write first_final; }%% raise Mail::Field::IncompleteParseError.new(Mail::MimeVersionElement, data, p) end diff --git a/lib/mail/parsers/phrase_lists_parser.rb b/lib/mail/parsers/phrase_lists_parser.rb index 0f66d3be5..a54733f2c 100644 --- a/lib/mail/parsers/phrase_lists_parser.rb +++ b/lib/mail/parsers/phrase_lists_parser.rb @@ -870,6 +870,10 @@ def self.parse(data) end end + if false + testEof + end + if p != eof || cs < 42 raise Mail::Field::IncompleteParseError.new(Mail::PhraseList, data, p) end diff --git a/lib/mail/parsers/phrase_lists_parser.rl b/lib/mail/parsers/phrase_lists_parser.rl index 722c3bbee..a897d3bcd 100644 --- a/lib/mail/parsers/phrase_lists_parser.rl +++ b/lib/mail/parsers/phrase_lists_parser.rl @@ -76,6 +76,10 @@ module Mail::Parsers %%write init; %%write exec; + if false + testEof + end + if p != eof || cs < %%{ write first_final; }%% raise Mail::Field::IncompleteParseError.new(Mail::PhraseList, data, p) end diff --git a/lib/mail/parsers/received_parser.rb b/lib/mail/parsers/received_parser.rb index b24c2f5b7..e998fe20a 100644 --- a/lib/mail/parsers/received_parser.rb +++ b/lib/mail/parsers/received_parser.rb @@ -8768,6 +8768,10 @@ def self.parse(data) end end + if false + testEof + end + if p != eof || cs < 648 raise Mail::Field::IncompleteParseError.new(Mail::ReceivedElement, data, p) end diff --git a/lib/mail/parsers/received_parser.rl b/lib/mail/parsers/received_parser.rl index 83242e7a8..0df1c242d 100644 --- a/lib/mail/parsers/received_parser.rl +++ b/lib/mail/parsers/received_parser.rl @@ -77,6 +77,10 @@ module Mail::Parsers %%write init; %%write exec; + if false + testEof + end + if p != eof || cs < %%{ write first_final; }%% raise Mail::Field::IncompleteParseError.new(Mail::ReceivedElement, data, p) end diff --git a/spec/mail/network/delivery_methods/smtp_connection_spec.rb b/spec/mail/network/delivery_methods/smtp_connection_spec.rb index 06aeaaeaf..22ac48424 100644 --- a/spec/mail/network/delivery_methods/smtp_connection_spec.rb +++ b/spec/mail/network/delivery_methods/smtp_connection_spec.rb @@ -16,8 +16,6 @@ end it "should not dot-stuff unterminated last line with no leading dot" do - body = "this is a test\n.\nonly a test" - Mail.deliver do from 'from@example.com' to 'to@example.com'