From 153a2256d5a2ed604a7486479e674c8b0cd7d181 Mon Sep 17 00:00:00 2001 From: Mauro Iazzi Date: Tue, 14 Apr 2009 13:41:22 +0200 Subject: [PATCH] dot-atom and quoted-string capture changed --- mime.lua | 6 +++--- test.lua | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mime.lua b/mime.lua index 163e3bf..45f6843 100644 --- a/mime.lua +++ b/mime.lua @@ -186,8 +186,8 @@ local lex_tokens = function () P("~"), -- RFC 2822 Section 3.2.4 -- an atom is equal to the content only discarding comments and whitespace ["atom"] = V("CFWS")^-1 * C(V("atext")^1) * V("CFWS")^-1, -- RFC 2822 Section 3.2.4 - -- an atom with dots is only the content - ["dot-atom"] = V("CFWS")^-1 * C(V("dot-atom-text")) * V("CFWS")^-1, -- RFC 2822 Section 3.2.4 + -- an atom with dots is only the content, discarding CFWSs + ["dot-atom"] = Cs((V("CFWS")^-1/'') * C(V("dot-atom-text")) * (V("CFWS")^-1/'')), -- RFC 2822 Section 3.2.4 -- the content of an atom text with dots ["dot-atom-text"] = V("atext")^1 * (P(".") * V("atext")^1)^0, -- RFC 2822 Section 3.2.4 -- character that can appear in a quoted string @@ -201,7 +201,7 @@ local lex_tokens = function () ["qcontent"] = C(V("qtext")) + V("quoted-pair"), -- RFC 2822 Section 3.2.5 -- a quoted string is equal to its content ["quoted-string"] = V("CFWS")^-1 * - P("\"") * ((V("FWS")^-1 * V("qcontent"))^0 * V("FWS")^-1)/join * P("\"") * V("CFWS")^-1, -- RFC 2822 Section 3.2.5 + P("\"") * Cs((V("FWS")^-1 * V("qcontent"))^0 * V("FWS")^-1) * P("\"") * V("CFWS")^-1, -- RFC 2822 Section 3.2.5 -- unstructured patterns for unspecified headers -- what should these be equal to? -- diff --git a/test.lua b/test.lua index eac5845..15ba6a2 100644 --- a/test.lua +++ b/test.lua @@ -54,6 +54,7 @@ local function equal (a, b) return false end +print("starting the tests ...") for i, t in ipairs(tests) do local s, r, m, c = t.string, t.rule, t.match, t.capture gr[1] = (lpeg.V(r)) / gather * lpeg.Cp() -- 2.11.4.GIT