diff options
author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2022-03-18 12:12:39 +0100 |
---|---|---|
committer | Caleb Maclennan <caleb@alerque.com> | 2022-03-19 17:13:15 +0300 |
commit | 601ad8d59f11d7180015d0ecfb9d0a8d67f6f5c1 (patch) | |
tree | e3b9c152b9ff8a431d1431edb0a42d051d256f13 /src/mbox.lua | |
parent | 480c05257211b3e566f33fdf8cf051233e2dab30 (diff) | |
download | luasocket-601ad8d59f11d7180015d0ecfb9d0a8d67f6f5c1.tar.gz luasocket-601ad8d59f11d7180015d0ecfb9d0a8d67f6f5c1.tar.bz2 luasocket-601ad8d59f11d7180015d0ecfb9d0a8d67f6f5c1.zip |
refactor: Address issues raised by linter
Diffstat (limited to 'src/mbox.lua')
-rw-r--r-- | src/mbox.lua | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/mbox.lua b/src/mbox.lua index ed9e781..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 "" |
@@ -63,7 +63,8 @@ end | |||
63 | function _M.split_mbox(mbox_s) | 63 | function _M.split_mbox(mbox_s) |
64 | local 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 |