Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle a wide variety of non-rfc Message-Id formats #607

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/mail/elements/message_ids_element.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def message_id
end

def clean_msg_id( val )
val =~ /.*<(.*)>.*/ ; $1
val =~ /.*<(.*)>.*/ ; $1 || val
end

end
Expand Down
5 changes: 4 additions & 1 deletion lib/mail/parsers/message_ids_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ def parse(s)
when :domain_e, :domain_s, :local_dot_atom_e,
:local_dot_atom_pre_comment_e,
:local_dot_atom_pre_comment_s,
:local_dot_atom_s
:local_dot_atom_s,
:qstr_s, :qstr_e,
:local_quoted_string_e,
:comment_s, :comment_e
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like the indentation is different in your change?


# ignored actions

Expand Down
33 changes: 25 additions & 8 deletions lib/mail/parsers/ragel/common.rl
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,36 @@

# message_ids
obs_id_left = local_part;
id_left = dot_atom_text | obs_id_left;
# id_right modifications to support multiple '@' in msg_id.
msg_id_atext = ALPHA | DIGIT | "!" | "#" | "$" | "%" | "&" | "'" | "*" |
"+" | "-" | "/" | "=" | "?" | "^" | "_" | "`" | "{" | "|" |
"}" | "~" | "@";
msg_id_dot_atom_text = (msg_id_atext+ "."?)+;
"}" | "~" | ":" | "," | "." | " ";
obs_id_right = domain;
no_fold_literal = "[" (dtext)* "]";
id_right = msg_id_dot_atom_text | no_fold_literal | obs_id_right;

id_left = msg_id_atext+ | obs_id_left;
id_left_ns = ( msg_id_atext - ( " " | "," ) )+;

# id_right modifications to support multiple '@' in msg_id.
id_right = ( msg_id_atext | "@" )+ | no_fold_literal | obs_id_right;
id_right_ns = ( msg_id_atext - ( " " | "," ) | "@" )+ | no_fold_literal;

# Handle various message-id formats:
# <id_left@id_right>
# <id_left@id_right...
# <id_left@>
# <id_left>
# <id_left...
# id_left@id_right
# id_left
# Handle comma-separated message_ids.
msg_id = (CFWS)?
(("<" id_left "@" id_right ">") >msg_id_s %msg_id_e)
(CFWS)?;
message_ids = msg_id (CFWS? msg_id)*;
( (("<" id_left "@" id_right? ">") >msg_id_s %msg_id_e) |
(("<" id_left "@" id_right? :>> "...") >msg_id_s %msg_id_e) |
(("<" id_left ">") >msg_id_s %msg_id_e) |
(("<" id_left :>> "..." ) >msg_id_s %msg_id_e) |
((id_left_ns ("@" id_right_ns)? ) >msg_id_s %msg_id_e ) )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you get away with only having the actions once or does that cause issues?

(
  ( (format1) | (format2) ) >msg_id_s %msg_id_e
)

(CFWS)? <: ","? ;
message_ids = msg_id**;

include date_time "date_time.rl";
date_time = (day_of_week ",")?
Expand Down
Loading