Re: Balsa can't download a mail with a long line, gets stuck in endless dup-creating loop.



Rob,

thanks for reporting the issue. I believe the attached patch should address the issue you see.

BTW, have you considered accessing gmail via IMAP and copying messages this way?

/Pawel

On 10/22/2012 07:33:01 PM, Rob Landley wrote:
I'm attempting to switch over to balsa (the version built into current
xubuntu lts, 2.4.11-1), and download a year or so of archives off
gmail via pop3. Since gmail only gives ~500 messages per pop session,
I told it to check mail once a minute and left it running overnight.

When I get up, it's stuck in an endless loop appending duplicate
messages to my inbox, because one of the messages won't download and
in that case it drops the connection rather than calling quit, meaning
none of the messages are deleted off the server, so it re-downloads
them (and hits the same error again) next time.

(Pause to write quick python program to detect/kill duplicates in inbox.)

A couple complicating factors:

1) The error message pops up in two xfce bubble that go away again in
about 3 seconds.

2) The message number it's complaining about is only identifiable via
the pop interface, not via gmail's web view.

(Pause to write quick python program to download a batch of pop
messages and write them to numbered files.)

I use said python program to delete the batch of mail it couldn't
download (but which I copied to separate files; it's from september
2011 anyway), and set it downloading again. It gets up to february of
this year, and does it again.

This time, I caught the line of text it was complaining about, which
starts with ">> Ethtool", and the word "Ethtool" is not in message 129
(as it said) but message 126 in the batch, which is attached.

I can't control what people on linux-kernel send me. Is there any way
to fix balsa?

Rob


diff --git a/libbalsa/imap/pop3.c b/libbalsa/imap/pop3.c
index cf5d76c..2387daa 100644
--- a/libbalsa/imap/pop3.c
+++ b/libbalsa/imap/pop3.c
@@ -650,10 +650,14 @@ pop_fetch_message_s(PopHandle *pop, unsigned msgno,
   resp = pop_check_status(pop, err);
   /* do here the fetch */
   if(resp) {
+    /* whether next line will be a continuation line. */
+    gboolean continuation_line = FALSE;
     while( sio_gets(pop->sio, line, sizeof(line)) &&
-           strcmp(line, ".\r\n") ) {
+           (continuation_line || strcmp(line, ".\r\n")) ) {
       char *arg = line[0] == '.' ? line+1 : line;
       unsigned len = strlen(arg);
+      continuation_line = (len >= POP_LINE_LEN-1);
+      printf("Line '%s'\n", line);
       if(pop->filter_cr && len>=2 && arg[len-2] == '\r') 
         arg[(--len)-1] = '\n';
       if(resp) 
@@ -663,6 +667,7 @@ pop_fetch_message_s(PopHandle *pop, unsigned msgno,
           resp = FALSE;
         }
     }
+    printf("LAST Line is '%s'\n", line);
   }
   return resp;
 }
@@ -743,10 +748,13 @@ pop_complete_retr(PopHandle *pop, PopAsyncCb cb, void *arg)
     cb(rc, arg, &err);
   if(resp) { /* same code as in fetch_message() */
     char * str;
+    /* whether next line will be a continuation line. */
+    gboolean continuation_line = FALSE;
     while( (str = sio_gets(pop->sio, line, sizeof(line))) &&
-           strcmp(line, ".\r\n") ) {
+           (continuation_line || strcmp(line, ".\r\n")) ) {
       char *buf = line[0] == '.' ? line+1 : line;
       unsigned len = strlen(buf);
+      continuation_line = (len >= POP_LINE_LEN-1);
       if(pop->filter_cr && len>=2 && buf[len-2] == '\r') 
         buf[(--len)-1] = '\n';
       if(cb) 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]