[dovecot-cvs] dovecot/src/lib-imap imap-quote.c,1.14,1.15

cras at procontrol.fi cras at procontrol.fi
Wed Jun 18 05:35:46 EEST 2003


Update of /home/cvs/dovecot/src/lib-imap
In directory danu:/tmp/cvs-serv29175/lib-imap

Modified Files:
	imap-quote.c 
Log Message:
LWSP stripping with NUL/8bit chars set wrong literal size which broke things.



Index: imap-quote.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-quote.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- imap-quote.c	4 Jun 2003 16:03:47 -0000	1.14
+++ imap-quote.c	18 Jun 2003 01:35:44 -0000	1.15
@@ -7,7 +7,7 @@
 void imap_quote_append(string_t *str, const unsigned char *value,
 		       size_t value_len)
 {
-	size_t i, linefeeds = 0;
+	size_t i, extra = 0;
 	int last_lwsp = TRUE, literal = FALSE, modify = FALSE;
 
 	if (value == NULL) {
@@ -23,23 +23,27 @@
 		case 0:
 			/* it's converted to 8bit char */
 			literal = TRUE;
-		case '\t':
 			modify = TRUE;
+			last_lwsp = FALSE;
 			break;
 		case ' ':
-			if (last_lwsp)
+		case '\t':
+			if (last_lwsp) {
 				modify = TRUE;
+				extra++;
+			}
 			last_lwsp = TRUE;
 			break;
 		case 13:
 		case 10:
-			linefeeds++;
+			extra++;
 			modify = TRUE;
 			break;
 		default:
 			if ((value[i] & 0x80) != 0 ||
 			    value[i] == '"' || value[i] == '\\')
 				literal = TRUE;
+			last_lwsp = FALSE;
 		}
 	}
 
@@ -48,7 +52,7 @@
 		str_append_c(str, '"');
 	} else {
 		/* return as literal */
-		str_printfa(str, "{%"PRIuSIZE_T"}\r\n", value_len - linefeeds);
+		str_printfa(str, "{%"PRIuSIZE_T"}\r\n", value_len - extra);
 	}
 
 	if (!modify)



More information about the dovecot-cvs mailing list