[imapfilter-devel] Moving mail between accounts failing
Lefteris Chatzibarbas
lefcha at hellug.gr
Sat Jun 4 12:05:16 EEST 2005
On Wed, Jun 01, 2005 at 01:31:14PM -0700, John Webster wrote:
>
> I'm trying to copy message between accounts on different servers,
> unfortunately the copying is failing with the following error
> message. Am I doing something wrong?
>
> imapfilter: /usr/local/share/imapfilter/interface.lua:251: bad argument #5 to `append' (string expected, got nil)
Hello
We tracked down the problem with John Webster. Actually, two problems,
a bug of imapfilter and a bug of the IMAP mail server that "advertises"
as:
* OK IMAP3 (internal) IMAP4rev1 Thu, 02 Jun 2005 08:42:00 -0700
I don't know which IMAP server this is, but it doesn't conforms to the
RFC3501 IMAP4rev1 specification. When imapfilter requests information
about a mail (size, date, flags):
100D UID FETCH 1 FAST
The server responds with:
* 1 FETCH (FLAGS () UID 1 RFC822.SIZE 8172 INTERNALDATE "1-Feb-2005 8:40:08 -0
^^^^^^^
^^^^^^^
But the IMAP4rev1 protocol requires that the time returned must be in
the following ABNF:
time = 2DIGIT ":" 2DIGIT ":" 2DIGIT
So the server should return, in the above case: "08:40:08"
I attach a patch for imapfilter's bug and a workaround for the IMAP
server bug, for those having problems. Patch against v1.0.1.
L.
-------------- next part --------------
diff -ruN imapfilter-1.0.1.orig/interface.lua imapfilter-1.0.1/interface.lua
--- imapfilter-1.0.1.orig/interface.lua 2005-02-13 17:54:03.000000000 +0200
+++ imapfilter-1.0.1/interface.lua 2005-06-02 13:17:03.000000000 +0300
@@ -463,8 +463,8 @@
for i, v in ipairs(messages) do
local _, fetch = ifcore.fetch(account, tostring(v), 'FAST')
if (fetch ~= nil) then
- local _, _, flags = string.find(fetch, 'FLAGS %((.*)%) ')
- local _, _, date = string.find(fetch, 'INTERNALDATE "(.*)" ')
+ local _, _, flags = string.find(fetch, 'FLAGS %(([^()]*)%)')
+ local _, _, date = string.find(fetch, 'INTERNALDATE "(.*)"')
local _, _, size = string.find(fetch, 'RFC822%.SIZE (%d+)')
local f = {}
for s in string.gfind(flags, '%w+') do
-------------- next part --------------
diff -ruN imapfilter-1.0.1.orig/interface.lua imapfilter-1.0.1/interface.lua
--- imapfilter-1.0.1.orig/interface.lua 2005-02-13 17:54:03.000000000 +0200
+++ imapfilter-1.0.1/interface.lua 2005-06-03 11:39:51.000000000 +0300
@@ -472,7 +472,7 @@
end
results[tonumber(v)] = {}
results[tonumber(v)]['flags'] = f
- results[tonumber(v)]['date'] = date
+ results[tonumber(v)]['date'] = string.gsub(date, " (%d):(%d%d):(%d%d) ", " 0%1:%2:%3 ")
results[tonumber(v)]['size'] = size
end
end
More information about the Imapfilter-devel
mailing list