Permalink
Browse files

Resolved Issue #8- Message ID not handling multiple periods in left h…

…and side
  • Loading branch information...
mikel committed Nov 12, 2009
1 parent 99a2302 commit 26bc1c1077c9627c62214c91a712d1a7915f4f08
View
@@ -1,3 +1,7 @@
+== Thu Nov 12 02:58:01 UTC 2009 Mikel Lindsaar <raasdnil@gmail.com>
+
+* Resolved Issue #8- Message ID not handling multiple periods in left hand side
+
== Tue Nov 10 08:15:14 UTC 2009 Mikel Lindsaar <raasdnil@gmail.com>
* Resolved Issue #5 - Message ID generation issue
@@ -961,6 +961,53 @@ def _nt_atext
r0
end
+ def _nt_mtext
+ start_index = index
+ if node_cache[:mtext].has_key?(index)
+ cached = node_cache[:mtext][index]
+ @index = cached.interval.end if cached
+ return cached
+ end
+
+ s0, i0 = [], index
+ loop do
+ i1 = index
+ r2 = _nt_atext
+ if r2
+ r1 = r2
+ else
+ if has_terminal?(".", false, index)
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
+ @index += 1
+ else
+ terminal_parse_failure(".")
+ r3 = nil
+ end
+ if r3
+ r1 = r3
+ else
+ @index = i1
+ r1 = nil
+ end
+ end
+ if r1
+ s0 << r1
+ else
+ break
+ end
+ end
+ if s0.empty?
+ @index = i0
+ r0 = nil
+ else
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
+ end
+
+ node_cache[:mtext][start_index] = r0
+
+ r0
+ end
+
module Atom0
end
@@ -1118,6 +1165,35 @@ def _nt_local_dot_atom
r0
end
+ def _nt_message_id_text
+ start_index = index
+ if node_cache[:message_id_text].has_key?(index)
+ cached = node_cache[:message_id_text][index]
+ @index = cached.interval.end if cached
+ return cached
+ end
+
+ s0, i0 = [], index
+ loop do
+ r1 = _nt_mtext
+ if r1
+ s0 << r1
+ else
+ break
+ end
+ end
+ if s0.empty?
+ @index = i0
+ r0 = nil
+ else
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
+ end
+
+ node_cache[:message_id_text][start_index] = r0
+
+ r0
+ end
+
module DotAtomText0
def domain_text
elements[0]
@@ -4378,7 +4454,7 @@ def _nt_id_left
end
i0 = index
- r1 = _nt_dot_atom_text
+ r1 = _nt_message_id_text
if r1
r0 = r1
else
@@ -84,6 +84,10 @@ module Mail
"|" / "}" /
"~"
end
+
+ rule mtext
+ (atext / ".")+
+ end
rule atom
CFWS? atext+ CFWS?
@@ -97,6 +101,10 @@ module Mail
CFWS? local_dot_atom_text CFWS?
end
+ rule message_id_text
+ mtext+
+ end
+
rule dot_atom_text
(domain_text "."?)+
end
@@ -360,7 +368,7 @@ module Mail
end
rule id_left
- dot_atom_text / no_fold_quote / obs_id_left
+ message_id_text / no_fold_quote / obs_id_left
end
rule id_right
@@ -33,5 +33,11 @@
msg_ids = Mail::MessageIdsElement.new(msg_id_text)
msg_ids.message_id.should == '1234@test.lindsaar.net'
end
+
+ it "should not fail to parse a message id with dots in it" do
+ text = "<4afb664ca3078_48dc..fdbe32b865532b@ax-desktop.mail>"
+ m = Mail::MessageIdsElement.new(text)
+ m.message_id.should == "4afb664ca3078_48dc..fdbe32b865532b@ax-desktop.mail"
+ end
end

0 comments on commit 26bc1c1

Please sign in to comment.