From nobody@FreeBSD.org  Thu Feb  3 21:24:40 2005
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 0AF7116A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  3 Feb 2005 21:24:40 +0000 (GMT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id CCF5243D48
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  3 Feb 2005 21:24:39 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j13LObCk037845
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 3 Feb 2005 21:24:37 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id j13LObqH037842;
	Thu, 3 Feb 2005 21:24:37 GMT
	(envelope-from nobody)
Message-Id: <200502032124.j13LObqH037842@www.freebsd.org>
Date: Thu, 3 Feb 2005 21:24:37 GMT
From: "Georg-W. Koltermann" <gwk@rahn-koltermann.de>
To: freebsd-gnats-submit@FreeBSD.org
Subject: evolution port needs fix for ximian bug 70556 (FIX ATTACHED)
X-Send-Pr-Version: www-2.3

>Number:         77076
>Category:       ports
>Synopsis:       evolution port needs fix for ximian bug 70556 (FIX ATTACHED)
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    gnome
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Feb 03 21:30:22 GMT 2005
>Closed-Date:    Fri Feb 11 07:34:34 GMT 2005
>Last-Modified:  Fri Feb 11 07:34:34 GMT 2005
>Originator:     Georg-W. Koltermann
>Release:        5.3
>Organization:
>Environment:
FreeBSD hunter.localnet 5.3-RELEASE FreeBSD 5.3-RELEASE #9: Wed Jan 19 12:11:29 CET 2005     gwk@hunter.localnet:/usr/obj/usr/src/sys/HUNTER  i386

>Description:
I found that the current evolution port (2.0.3) hangs when accessing
my Lotus Notes IMAP account.  The message was "evolution-2.0:1002): camel-imap-provider-WARNING **: Server sent empty line after a literal, assuming in error"

Searching the net I found that this is bug 70556 in Ximian bugzilla,
and is fixed by the patch enclosed below. The patch did solve my
problem.

I think we should add the patch to our port.

>How-To-Repeat:
      
>Fix:
Index: camel/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/camel/ChangeLog,v
retrieving revision 1.2251.2.28
diff -u -p -r1.2251.2.28 ChangeLog
--- camel/ChangeLog     3 Dec 2004 03:03:02 -0000       1.2251.2.28
+++ camel/ChangeLog     23 Dec 2004 07:23:55 -0000
@@ -1,3 +1,12 @@
+2004-12-23  Not Zed  <NotZed@Ximian.com>
+
+       ** See bug #70556.
+
+       * providers/imap/camel-imap-command.c (imap_read_untagged): scan
+       the non-literal contnet for s-expression brackets, and if we seem
+       to be outside of one, don't try the 'blank line after literal'
+       hack.
+
 2004-12-02  Not Zed  <NotZed@Ximian.com>

        ** See bug #69533.
Index: camel/providers/imap/camel-imap-command.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/providers/imap/camel-imap-command.c,v
retrieving revision 1.60.26.2
diff -u -p -r1.60.26.2 camel-imap-command.c
--- camel/providers/imap/camel-imap-command.c   3 Dec 2004 03:03:02 -0000       1.60.26.2
+++ camel/providers/imap/camel-imap-command.c   23 Dec 2004 07:23:56 -0000
@@ -43,7 +43,7 @@
 #include <camel/camel-private.h>
 #include <camel/camel-utf8.h>
 #include <camel/camel-session.h>
-
+#include <camel/camel-debug.h>

 extern int camel_verbose_debug;

@@ -409,7 +409,7 @@ imap_read_response (CamelImapStore *stor
 static char *
 imap_read_untagged (CamelImapStore *store, char *line, CamelException *ex)
 {
-       int fulllen, ldigits, nread, i;
+       int fulllen, ldigits, nread, i, sexp = 0;
        unsigned int length;
        GPtrArray *data;
        GString *str;
@@ -431,6 +431,18 @@ imap_read_untagged (CamelImapStore *stor
                p = strrchr (str->str, '{');
                if (!p)
                        break;
+
+               /* HACK ALERT: We scan the non-literal part of the string, looking for possible s expression braces.
+                  This assumes we're getting s-expressions, which we should be.
+                  This is so if we get a blank line after a literal, in an s-expression, we can keep going, since
+                  we do no other parsing at this level.
+                  TODO: handle quoted strings? */
+               for (s=str->str; s<p; s++) {
+                       if (*s == '(')
+                               sexp++;
+                       else if (*s == ')')
+                               sexp--;
+               }

                length = strtoul (p + 1, &end, 10);
                if (*end != '}' || *(end + 1) || end == p + 1 || length >= UINT_MAX - 2)
@@ -460,6 +472,12 @@ imap_read_untagged (CamelImapStore *stor
                        goto lose;
                }
                str->str[length + 1] = '\0';
+
+               if (camel_debug("imap")) {
+                       printf("Literal: -->");
+                       fwrite(str->str+1, 1, length, stdout);
+                       printf("<--\n");
+               }

                /* Fix up the literal, turning CRLFs into LF. Also, if
                 * we find any embedded NULs, strip them. This is
@@ -505,10 +523,11 @@ imap_read_untagged (CamelImapStore *stor
                        if (camel_imap_store_readline (store, &line, ex) < 0)
                                goto lose;

-                       /* MAJOR HACK ALERT, gropuwise sometimes sends an extra blank line after literals, check that here */
-                       if (line[0] == 0)
+                       /* MAJOR HACK ALERT, gropuwise sometimes sends an extra blank line after literals, check that here
+                          But only do it if we're inside an sexpression */
+                       if (line[0] == 0 && sexp > 0)
                                g_warning("Server sent empty line after a literal, assuming in error");
-               } while (line[0] == 0);
+               } while (line[0] == 0 && sexp > 0);
        }

        /* Now reassemble the data. */

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->gnome 
Responsible-Changed-By: vs 
Responsible-Changed-When: Fri Feb 4 15:06:00 GMT 2005 
Responsible-Changed-Why:  
This is GNOME territory. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=77076 
State-Changed-From-To: open->feedback 
State-Changed-By: marcus 
State-Changed-When: Wed Feb 9 06:04:30 GMT 2005 
State-Changed-Why:  
This patch does not apply.  It looks like you pasted this patch into the PR, 
and thus all of the tabs became spaces.  Please resubmit the patch, or 
better yet, post it to a website. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=77076 

From: "Georg-W. Koltermann" <Georg.Koltermann@mscsoftware.com>
To: freebsd-gnats-submit@FreeBSD.org, gwk@rahn-koltermann.de
Cc:  
Subject: Re: ports/77076: evolution port needs fix for ximian bug  70556
	(FIX ATTACHED)
Date: Wed, 09 Feb 2005 11:00:40 +0100

 Yes I did paste the fix.  Sorry for the breakage.
 
 The fix can also be retrieved directly from Ximian bugzilla at
 http://bugzilla.ximian.com/showattachment.cgi?attach_id=13585
 
 --
 Regards,
 gwk
 
State-Changed-From-To: feedback->closed 
State-Changed-By: marcus 
State-Changed-When: Fri Feb 11 07:34:23 GMT 2005 
State-Changed-Why:  
Committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=77076 
>Unformatted:
