diff options
Diffstat (limited to '')
-rw-r--r-- | src/mbox.lua | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/mbox.lua b/src/mbox.lua index 7724ae2..12823b0 100644 --- a/src/mbox.lua +++ b/src/mbox.lua | |||
@@ -1,8 +1,8 @@ | |||
1 | local _M = {} | 1 | local _M = {} |
2 | 2 | ||
3 | if module then | 3 | if module then |
4 | mbox = _M | 4 | mbox = _M -- luacheck: ignore |
5 | end | 5 | end |
6 | 6 | ||
7 | function _M.split_message(message_s) | 7 | function _M.split_message(message_s) |
8 | local message = {} | 8 | local message = {} |
@@ -29,7 +29,7 @@ end | |||
29 | function _M.parse_header(header_s) | 29 | function _M.parse_header(header_s) |
30 | header_s = string.gsub(header_s, "\n[ ]+", " ") | 30 | header_s = string.gsub(header_s, "\n[ ]+", " ") |
31 | header_s = string.gsub(header_s, "\n+", "") | 31 | header_s = string.gsub(header_s, "\n+", "") |
32 | local _, __, name, value = string.find(header_s, "([^%s:]-):%s*(.*)") | 32 | local _, _, name, value = string.find(header_s, "([^%s:]-):%s*(.*)") |
33 | return name, value | 33 | return name, value |
34 | end | 34 | end |
35 | 35 | ||
@@ -49,9 +49,9 @@ function _M.parse_headers(headers_s) | |||
49 | end | 49 | end |
50 | 50 | ||
51 | function _M.parse_from(from) | 51 | function _M.parse_from(from) |
52 | local _, __, name, address = string.find(from, "^%s*(.-)%s*%<(.-)%>") | 52 | local _, _, name, address = string.find(from, "^%s*(.-)%s*%<(.-)%>") |
53 | if not address then | 53 | if not address then |
54 | _, __, address = string.find(from, "%s*(.+)%s*") | 54 | _, _, address = string.find(from, "%s*(.+)%s*") |
55 | end | 55 | end |
56 | name = name or "" | 56 | name = name or "" |
57 | address = address or "" | 57 | address = address or "" |
@@ -61,9 +61,10 @@ function _M.parse_from(from) | |||
61 | end | 61 | end |
62 | 62 | ||
63 | function _M.split_mbox(mbox_s) | 63 | function _M.split_mbox(mbox_s) |
64 | mbox = {} | 64 | local mbox = {} |
65 | mbox_s = string.gsub(mbox_s, "\r\n", "\n") .."\n\nFrom \n" | 65 | mbox_s = string.gsub(mbox_s, "\r\n", "\n") .."\n\nFrom \n" |
66 | local nj, i, j = 1, 1, 1 | 66 | local nj, i |
67 | local j = 1 | ||
67 | while 1 do | 68 | while 1 do |
68 | i, nj = string.find(mbox_s, "\n\nFrom .-\n", j) | 69 | i, nj = string.find(mbox_s, "\n\nFrom .-\n", j) |
69 | if not i then break end | 70 | if not i then break end |