mbox: read a 30kb chunk by default

This commit is contained in:
Adrian C. (anrxc) 2009-10-05 00:11:44 +02:00
parent 4602ca2fa5
commit c84f515690
1 changed files with 15 additions and 13 deletions

View File

@ -17,16 +17,21 @@ module("vicious.mbox")
-- {{{ Mailbox widget type
local function worker(format, mbox)
-- mbox could be huge, get a 15kb chunk from EOF
-- mbox could be huge, get a 30kb chunk from EOF
-- * attachments could be much bigger than this
local f = io.open(mbox)
f:seek("end", -15360)
f:seek("end", -30720)
local txt = f:read("*all")
f:close()
-- Default value
local subject = "N/A"
-- Find all Subject lines
for s in string.gfind(txt, "Subject: ([^\n]*)") do subject = s end
if subject then
for i in string.gfind(txt, "Subject: ([^\n]*)") do
subject = i
end
-- Spam sanitize only the last subject
subject = helpers.escape(subject)
@ -34,9 +39,6 @@ local function worker(format, mbox)
subject = helpers.truncate(subject, 22)
return {subject}
else
return {"N/A"}
end
end
-- }}}