[evolution-patches] possible 1.4 bug, 51758, spaces in addresses




Hi,

This patch is against head, and before i try to make one for 1.4, i thought i'd bring it up for discussion (it might even apply cleanly anyway, its all camel stuff).

The diff includes a couple of other minor unrelated changes because they were just messy to remove.  It also looks big because of some namespacing/exporting of functions, the meaningful changes are confined to camel-internet-address and camel-smtp-transport.

It fixes most of the cases where you can get spaces (or other special characters) in addresses (it *doesn't* fix header formatting - but thats because we let the html encoder find inline addresses, we can easily fix this in the formatter).

I'm just wondreing if its worth putting in 1.4, it'll go into head shortly.

Michael

? 19564.diff
? a
? all.txt
? buildtable
? c.diff
? camel-f.c
? camel-service.2.c
? camel-stream-ssl.c
? camel-stream-ssl.h
? camel-stream.0.html
? camel-stream.1.html
? camel-thread.h
? cia.diff
? cvf.c
? diff
? filter.diff
? foo.c
? imap.cplug
? log
? merged.msg
? mt.diff
? mylock
? names.txt
? new
? old
? out.ps
? out.txt
? outbox
? plugin
? plugin.c
? plugin.txt
? race.txt
? search.txt
? test-from.c
? test-ssl
? test-ssl.c
? test.c
? trace
? trash.diff
? typescript
? vfolder.txt
? vfolders.xml
? providers/cache
? providers/file
? providers/imap/a.diff
? providers/imap/callgraph.ps
? providers/imap/camel-imap-command.c.00.rtl
? providers/imap/camel-imap-folder.c.00.rtl
? providers/imap/camel-imap-message-cache.c.00.rtl
? providers/imap/camel-imap-provider.c.00.rtl
? providers/imap/camel-imap-search.c.00.rtl
? providers/imap/camel-imap-store-summary.c.00.rtl
? providers/imap/camel-imap-store.c.00.rtl
? providers/imap/camel-imap-summary.c.00.rtl
? providers/imap/camel-imap-utils.c.00.rtl
? providers/imap/camel-imap-wrapper.c.00.rtl
? providers/imapp/camel-imapp-driver.c.00.rtl
? providers/imapp/camel-imapp-engine.c.00.rtl
? providers/imapp/camel-imapp-folder.c.00.rtl
? providers/imapp/camel-imapp-provider.c.00.rtl
? providers/imapp/camel-imapp-store-summary.c.00.rtl
? providers/imapp/camel-imapp-store.c.00.rtl
? providers/imapp/camel-imapp-stream.c.00.rtl
? providers/imapp/camel-imapp-summary.c.00.rtl
? providers/imapp/camel-imapp-utils.c.00.rtl
? providers/imapp/cmc-imap.c
? providers/imapp/cmc-session.c
? providers/imapp/cmc-session.h
? providers/imapp/imapp-callgraph.ps
? providers/imapp/test-2.c
? providers/imapp/test-driver.c
? providers/imapp/test-engine.c
? providers/imapp/tok.c
? providers/local/camel-mbox-provider.c
? providers/local/swummary.txt
? providers/mbox/Makefile
? providers/mbox/Makefile.in
? providers/mbox/an
? providers/mh/Makefile
? providers/mh/Makefile.in
? providers/pop3/camel-pop3-engine.c.00.rtl
? providers/pop3/camel-pop3-folder.c.00.rtl
? providers/pop3/camel-pop3-provider.c.00.rtl
? providers/pop3/camel-pop3-store.c.00.rtl
? providers/pop3/camel-pop3-stream.c.00.rtl
? providers/vee/Makefile
? providers/vee/Makefile.in
? providers/vee/camel-vee-folder.c.save
? providers/vee/camel-vee-folder.c.save2
? providers/vee/diff
? providers/vee/libcamelvee.urls
? tests/a.out
? tests/camel-mime-tests.tar.gz
? tests/test.c
? tests/data/addr.txt
? tests/data/bg_BG.cp1251.windows-1251.txt
? tests/data/ca.iso-8859-1.txt
? tests/data/cs.ISO-8859-2.txt
? tests/data/da.ISO-8859-1.txt
? tests/data/de.ISO-8859-1.txt
? tests/data/el.iso-8859-7.txt
? tests/data/en_GB.iso-8859-1.txt
? tests/data/es.iso-8859-1.txt
? tests/data/et.iso-8859-1.txt
? tests/data/eu.iso-8859-1.txt
? tests/data/fi.iso-8859-15.txt
? tests/data/fr.ISO-8859-1.txt
? tests/data/ga.iso-8859-1.txt
? tests/data/gl.iso-8859-1.txt
? tests/data/hu.iso-8859-2.txt
? tests/data/it.iso-8859-1.txt
? tests/data/ja.euc-jp.txt
? tests/data/ko.euc-kr.txt
? tests/data/lt.iso-8859-13.txt
? tests/data/messages
? tests/data/nl.iso-8859-1.txt
? tests/data/no.iso-8859-1.txt
? tests/data/pl.iso-8859-2.txt
? tests/data/pt.iso-8859-1.txt
? tests/data/pt_BR.iso-8859-1.txt
? tests/data/ru.koi8-r.txt
? tests/data/sk.iso-8859-2.txt
? tests/data/sl.iso-8859-2.txt
? tests/data/sp.iso-8859-5.txt
? tests/data/sr.iso-8859-2.txt
? tests/data/sv.iso-8859-1.txt
? tests/data/ta.TSCII.txt
? tests/data/test-lines.h
? tests/data/tr.iso-8859-9.txt
? tests/data/uk.koi8-u.txt
? tests/data/wa.iso-8859-1.txt
? tests/data/zh_CN.GB2312.gb2312.txt
? tests/data/zh_TW.Big5.big5.txt
? tests/folder/test10
? tests/folder/trace
? tests/message/test4
? tests/message/uni.txt
? tests/mime-filter/test-html.c
? tests/mime-filter/test-tohtml
? tests/stream/readwrite.c
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/camel/ChangeLog,v
retrieving revision 1.1934
diff -u -3 -r1.1934 ChangeLog
--- ChangeLog	6 Dec 2003 18:04:03 -0000	1.1934
+++ ChangeLog	9 Dec 2003 00:19:29 -0000
@@ -1,3 +1,25 @@
+2003-12-09  Not Zed  <NotZed Ximian com>
+
+	* providers/smtp/camel-smtp-transport.c (smtp_send_to): encode the
+	address before sending it out, rather than using the raw/utf8
+	version.
+
+	* camel-internet-address.c
+	(camel_internet_address_encode_address): check for quoting the
+	local part of the address before outputting it.
+	(cia_encode_addrspec): quote local part if need be.
+	(camel_internet_address_encode_address): make folding optional
+	based on whether inlen is null or not.
+
+	* camel-mime-utils.[ch]: rename is_* to camel_mime_is_* and export
+	the type functions.
+
+2003-12-08  Not Zed  <NotZed Ximian com>
+
+	* providers/imap/camel-imap-utils.c (imap_atom_specials): add } to
+	the atom specials list.  This isn't correct, but some busted
+	servers expect it.  Bug #50728.
+
 2003-12-06  JP Rosevear <jpr ximian com>
 
 	* */Makefile.am: Remove hard coded disable deprecated flags
@@ -43,6 +65,14 @@
 
 2003-12-02  Not Zed  <NotZed Ximian com>
 
+	* providers/local/camel-local-folder.c (local_setv): remove some
+	debug printfs.
+
+	** See bug #51576.
+
+	* camel-url.c (camel_url_decode): robustify url decoding for bad
+	input, addresses a crash.
+
 	** See bug #51478.
 
 	* camel-gpg-context.c (gpg_ctx_free): handle the context being
Index: camel-internet-address.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-internet-address.c,v
retrieving revision 1.30
diff -u -3 -r1.30 camel-internet-address.c
--- camel-internet-address.c	18 Sep 2003 17:06:20 -0000	1.30
+++ camel-internet-address.c	9 Dec 2003 00:19:30 -0000
@@ -399,6 +399,43 @@
 	return -1;
 }
 
+static void
+cia_encode_addrspec(GString *out, const char *addr)
+{
+	const char *at, *p;
+
+	at = strchr(addr, '@');
+	if (at == NULL)
+		goto append;
+
+	p = addr;
+	while (p < at) {
+		char c = *p++;
+
+		/* strictly by rfc, we should split local parts on dots.
+		   however i think 2822 changes this, and not many clients grok it, so
+		   just quote the whole local part if need be */
+		if (!(camel_mime_is_atom(c) || c=='.')) {
+			g_string_append_c(out, '"');
+
+			p = addr;
+			while (p < at) {
+				c = *p++;
+				if (c == '"' || c == '\\')
+					g_string_append_c(out, '\\');
+				g_string_append_c(out, c);
+			}
+			g_string_append_c(out, '"');
+			g_string_append(out, p);
+
+			return;
+		}
+	}
+
+append:
+	g_string_append(out, addr);
+}
+
 /**
  * camel_internet_address_encode_address:
  * @len: The encoded length so far, of this line
@@ -406,7 +443,8 @@
  * @addr: 
  * 
  * Encode a single address ready for internet usage.  Header folding
- * as per rfc 822 is also performed, based on the length in len.
+ * as per rfc 822 is also performed, based on the length * inlen   If @inlen
+ * is NULL, then no folding will occur.
  * 
  * Return value: The encoded address.
  **/
@@ -414,14 +452,17 @@
 camel_internet_address_encode_address(int *inlen, const char *real, const char *addr)
 {
 	char *name = camel_header_encode_phrase(real);
-	char *ret = NULL, *addra = NULL;
-	int len = *inlen;
+	char *ret = NULL;
+	int len = 0;
 	GString *out = g_string_new("");
 
 	g_assert(addr);
 
+	if (inlen != NULL)
+		len = *inlen;
+
 	if (name && name[0]) {
-		if (strlen(name) + len > CAMEL_FOLD_SIZE) {
+		if (inlen != NULL && (strlen(name) + len) > CAMEL_FOLD_SIZE) {
 			char *folded = camel_header_address_fold(name, len);
 			char *last;
 			g_string_append(out, folded);
@@ -435,36 +476,38 @@
 			g_string_append(out, name);
 			len += strlen(name);
 		}
-		addr = addra = g_strdup_printf(" <%s>", addr);
 	}
 
 	/* NOTE: Strictly speaking, we could and should split the
 	 * internal address up if we need to, on atom or specials
 	 * boundaries - however, to aid interoperability with mailers
 	 * that will probably not handle this case, we will just move
-	 * the whole address to its own line */
-	if (strlen(addr) + len > CAMEL_FOLD_SIZE) {
+	 * the whole address to its own line. */
+	if (inlen != NULL && (strlen(addr) + len) > CAMEL_FOLD_SIZE) {
 		g_string_append(out, "\n\t");
-		g_string_append(out, addr);
-		len = strlen(addr)+1;
-	} else {
-		g_string_append(out, addr);
-		len += strlen(addr);
+		len = 1;
 	}
 
-	*inlen = len;
-#if 0
+	len -= out->len;
+
 	if (name && name[0])
-		ret = g_strdup_printf("%s <%s>", name, addr);
-	else
-		ret = g_strdup_printf("%s", addr);
-#endif
+		g_string_append_printf(out, " <");
+	cia_encode_addrspec(out, addr);
+	if (name && name[0])
+		g_string_append_printf(out, ">");
+
+	len += out->len;
+	
+	if (inlen != NULL)
+		*inlen = len;
+
 	g_free(name);
-	g_free(addra);
 	
 	ret = out->str;
 	g_string_free(out, FALSE);
 
+	printf("encode address '%s %s' => %s\n", real, addr, ret);
+
 	return ret;
 }
 
Index: camel-mime-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-mime-utils.c,v
retrieving revision 1.199
diff -u -3 -r1.199 camel-mime-utils.c
--- camel-mime-utils.c	1 Dec 2003 01:30:45 -0000	1.199
+++ camel-mime-utils.c	9 Dec 2003 00:19:55 -0000
@@ -83,34 +83,9 @@
 	'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
 };
 
-static unsigned short camel_mime_special_table[256];
+unsigned short camel_mime_special_table[256];
 static unsigned char camel_mime_base64_rank[256];
 
-/* Flags bits set in the mime_special table, use the is_*() mactos to access them normally */
-enum {
-	IS_CTRL		= 1<<0,
-	IS_LWSP		= 1<<1,
-	IS_TSPECIAL	= 1<<2,
-	IS_SPECIAL	= 1<<3,
-	IS_SPACE	= 1<<4,
-	IS_DSPECIAL	= 1<<5,
-	IS_QPSAFE	= 1<<6,
-	IS_ESAFE	= 1<<7,	/* encoded word safe */
-	IS_PSAFE	= 1<<8,	/* encoded word in phrase safe */
-};
-
-#define is_ctrl(x) ((camel_mime_special_table[(unsigned char)(x)] & IS_CTRL) != 0)
-#define is_lwsp(x) ((camel_mime_special_table[(unsigned char)(x)] & IS_LWSP) != 0)
-#define is_tspecial(x) ((camel_mime_special_table[(unsigned char)(x)] & IS_TSPECIAL) != 0)
-#define is_type(x, t) ((camel_mime_special_table[(unsigned char)(x)] & (t)) != 0)
-#define is_ttoken(x) ((camel_mime_special_table[(unsigned char)(x)] & (IS_TSPECIAL|IS_LWSP|IS_CTRL)) == 0)
-#define is_atom(x) ((camel_mime_special_table[(unsigned char)(x)] & (IS_SPECIAL|IS_SPACE|IS_CTRL)) == 0)
-#define is_dtext(x) ((camel_mime_special_table[(unsigned char)(x)] & IS_DSPECIAL) == 0)
-#define is_fieldname(x) ((camel_mime_special_table[(unsigned char)(x)] & (IS_CTRL|IS_SPACE)) == 0)
-#define is_qpsafe(x) ((camel_mime_special_table[(unsigned char)(x)] & IS_QPSAFE) != 0)
-#define is_especial(x) ((camel_mime_special_table[(unsigned char)(x)] & IS_ESPECIAL) != 0)
-#define is_psafe(x) ((camel_mime_special_table[(unsigned char)(x)] & IS_PSAFE) != 0)
-
 /* Used by table initialisation code for special characters */
 #define CHARS_LWSP " \t\n\r"
 #define CHARS_TSPECIAL "()<>@,;:\\\"/[]?="
@@ -170,20 +145,20 @@
 	for (i=0;i<256;i++) {
 		camel_mime_special_table[i] = 0;
 		if (i<32)
-			camel_mime_special_table[i] |= IS_CTRL;
+			camel_mime_special_table[i] |= CAMEL_MIME_IS_CTRL;
 		if ((i>=32 && i<=60) || (i>=62 && i<=126) || i==9)
-			camel_mime_special_table[i] |= (IS_QPSAFE|IS_ESAFE);
+			camel_mime_special_table[i] |= (CAMEL_MIME_IS_QPSAFE|CAMEL_MIME_IS_ESAFE);
 		if ((i>='0' && i<='9') || (i>='a' && i<='z') || (i>='A' && i<= 'Z'))
-			camel_mime_special_table[i] |= IS_PSAFE;
+			camel_mime_special_table[i] |= CAMEL_MIME_IS_PSAFE;
 	}
-	camel_mime_special_table[127] |= IS_CTRL;
-	camel_mime_special_table[' '] |= IS_SPACE;
-	header_init_bits(IS_LWSP, 0, 0, CHARS_LWSP);
-	header_init_bits(IS_TSPECIAL, IS_CTRL, 0, CHARS_TSPECIAL);
-	header_init_bits(IS_SPECIAL, 0, 0, CHARS_SPECIAL);
-	header_init_bits(IS_DSPECIAL, 0, FALSE, CHARS_DSPECIAL);
-	header_remove_bits(IS_ESAFE, CHARS_ESPECIAL);
-	header_init_bits(IS_PSAFE, 0, 0, CHARS_PSPECIAL);
+	camel_mime_special_table[127] |= CAMEL_MIME_IS_CTRL;
+	camel_mime_special_table[' '] |= CAMEL_MIME_IS_SPACE;
+	header_init_bits(CAMEL_MIME_IS_LWSP, 0, 0, CHARS_LWSP);
+	header_init_bits(CAMEL_MIME_IS_TSPECIAL, CAMEL_MIME_IS_CTRL, 0, CHARS_TSPECIAL);
+	header_init_bits(CAMEL_MIME_IS_SPECIAL, 0, 0, CHARS_SPECIAL);
+	header_init_bits(CAMEL_MIME_IS_DSPECIAL, 0, FALSE, CHARS_DSPECIAL);
+	header_remove_bits(CAMEL_MIME_IS_ESAFE, CHARS_ESPECIAL);
+	header_init_bits(CAMEL_MIME_IS_PSAFE, 0, 0, CHARS_PSPECIAL);
 }
 
 static void
@@ -669,7 +644,7 @@
 	if (last != -1) {
 		/* space/tab must be encoded if it's the last character on
 		   the line */
-		if (is_qpsafe(last) && last!=' ' && last!=9) {
+		if (camel_mime_is_qpsafe(last) && last!=' ' && last!=9) {
 			*outptr++ = last;
 		} else {
 			*outptr++ = '=';
@@ -717,7 +692,7 @@
 			last = -1;
 		} else {
 			if (last != -1) {
-				if (is_qpsafe(last)) {
+				if (camel_mime_is_qpsafe(last)) {
 					*outptr++ = last;
 					sofar++;
 				} else {
@@ -728,7 +703,7 @@
 				}
 			}
 			
-			if (is_qpsafe(c)) {
+			if (camel_mime_is_qpsafe(c)) {
 				if (sofar > 74) {
 					*outptr++ = '=';
 					*outptr++ = '\n';
@@ -947,8 +922,8 @@
 
 	d2(printf("is ws: '%s'\n", *in));
 
-	while (is_lwsp(*inptr) || (*inptr =='(' && *inptr != '\0')) {
-		while (is_lwsp(*inptr) && inptr != '\0') {
+	while (camel_mime_is_lwsp(*inptr) || (*inptr =='(' && *inptr != '\0')) {
+		while (camel_mime_is_lwsp(*inptr) && inptr != '\0') {
 			d2(printf("(%c)", *inptr));
 			inptr++;
 		}
@@ -1156,7 +1131,7 @@
 
 	while (inptr < inend) {
 		start = inptr;
-		while (inptr < inend && is_lwsp(*inptr))
+		while (inptr < inend && camel_mime_is_lwsp(*inptr))
 			inptr++;
 
 		if (inptr == inend) {
@@ -1169,7 +1144,7 @@
 		}
 
 		start = inptr;
-		while (inptr < inend && !is_lwsp(*inptr))
+		while (inptr < inend && !camel_mime_is_lwsp(*inptr))
 			inptr++;
 
 		dword = rfc2047_decode_word(start, inptr-start);
@@ -1372,7 +1347,7 @@
 				if (last_was_encoded)
 					g_string_append_c (out, ' ');
 				
-				rfc2047_encode_word (out, start, inptr - start, "ISO-8859-1", IS_ESAFE);
+				rfc2047_encode_word (out, start, inptr - start, "ISO-8859-1", CAMEL_MIME_IS_ESAFE);
 				last_was_encoded = TRUE;
 				break;
 			case 2:
@@ -1380,7 +1355,7 @@
 					g_string_append_c (out, ' ');
 				
 				rfc2047_encode_word (out, start, inptr - start,
-						     camel_charset_best (start, inptr - start), IS_ESAFE);
+						     camel_charset_best (start, inptr - start), CAMEL_MIME_IS_ESAFE);
 				last_was_encoded = TRUE;
 				break;
 			}
@@ -1419,14 +1394,14 @@
 			if (last_was_encoded)
 				g_string_append_c (out, ' ');
 			
-			rfc2047_encode_word (out, start, inptr - start, "ISO-8859-1", IS_ESAFE);
+			rfc2047_encode_word (out, start, inptr - start, "ISO-8859-1", CAMEL_MIME_IS_ESAFE);
 			break;
 		case 2:
 			if (last_was_encoded)
 				g_string_append_c (out, ' ');
 			
 			rfc2047_encode_word (out, start, inptr - start,
-					     camel_charset_best (start, inptr - start - 1), IS_ESAFE);
+					     camel_charset_best (start, inptr - start - 1), CAMEL_MIME_IS_ESAFE);
 			break;
 		}
 	}
@@ -1532,7 +1507,7 @@
 		} else {
 			count++;
 			if (c < 128) {
-				if (!is_atom (c))
+				if (!camel_mime_is_atom (c))
 					type = MAX (type, WORD_QSTRING);
 			} else if (c > 127 && c < 256) {
 				type = WORD_2047;
@@ -1666,10 +1641,10 @@
 			}
 			
 			if (word->encoding == 1)
-				rfc2047_encode_word (out, start, len, "ISO-8859-1", IS_PSAFE);
+				rfc2047_encode_word (out, start, len, "ISO-8859-1", CAMEL_MIME_IS_PSAFE);
 			else
 				rfc2047_encode_word (out, start, len,
-						     camel_charset_best (start, len), IS_PSAFE);
+						     camel_charset_best (start, len), CAMEL_MIME_IS_PSAFE);
 			break;
 		}
 		
@@ -1700,7 +1675,7 @@
 	
 	header_decode_lwsp (&inptr);
 	start = inptr;
-	while (is_ttoken (*inptr))
+	while (camel_mime_is_ttoken (*inptr))
 		inptr++;
 	if (inptr > start) {
 		*in = inptr;
@@ -1765,7 +1740,7 @@
 
 	header_decode_lwsp(&inptr);
 	start = inptr;
-	while (is_atom(*inptr))
+	while (camel_mime_is_atom(*inptr))
 		inptr++;
 	*in = inptr;
 	if (inptr > start)
@@ -1798,7 +1773,7 @@
 	if (*inptr == '"') {
 		d(printf("decoding quoted string\n"));
 		return header_decode_quoted_string(in);
-	} else if (is_ttoken(*inptr)) {
+	} else if (camel_mime_is_ttoken(*inptr)) {
 		d(printf("decoding token\n"));
 		/* this may not have the right specials for all params? */
 		return decode_token(in);
@@ -1920,7 +1895,7 @@
 	
 	header_decode_lwsp (&inptr);
 	start = inptr;
-	while (is_ttoken (*inptr) && *inptr != '*')
+	while (camel_mime_is_ttoken (*inptr) && *inptr != '*')
 		inptr++;
 	if (inptr > start) {
 		*in = inptr;
@@ -1931,34 +1906,34 @@
 }
 
 static gboolean
-header_decode_rfc2184_param (const char **in, char **paramp, gboolean *value_is_encoded, int *part)
+header_decode_rfc2184_param (const char **in, char **paramp, gboolean *value_camel_mime_is_encoded, int *part)
 {
-	gboolean is_rfc2184 = FALSE;
+	gboolean camel_mime_is_rfc2184 = FALSE;
 	const char *inptr = *in;
 	char *param;
 	
-	*value_is_encoded = FALSE;
+	*value_camel_mime_is_encoded = FALSE;
 	*part = -1;
 	
 	param = decode_param_token (&inptr);
 	header_decode_lwsp (&inptr);
 	
 	if (*inptr == '*') {
-		is_rfc2184 = TRUE;
+		camel_mime_is_rfc2184 = TRUE;
 		inptr++;
 		header_decode_lwsp (&inptr);
 		if (*inptr == '=') {
 			/* form := param*=value */
-			if (value_is_encoded)
-				*value_is_encoded = TRUE;
+			if (value_camel_mime_is_encoded)
+				*value_camel_mime_is_encoded = TRUE;
 		} else {
 			/* form := param*#=value or param*#*=value */
 			*part = camel_header_decode_int (&inptr);
 			header_decode_lwsp (&inptr);
 			if (*inptr == '*') {
 				/* form := param*#*=value */
-				if (value_is_encoded)
-					*value_is_encoded = TRUE;
+				if (value_camel_mime_is_encoded)
+					*value_camel_mime_is_encoded = TRUE;
 				inptr++;
 				header_decode_lwsp (&inptr);
 			}
@@ -1971,28 +1946,28 @@
 	if (param)
 		*in = inptr;
 	
-	return is_rfc2184;
+	return camel_mime_is_rfc2184;
 }
 
 static int
-header_decode_param (const char **in, char **paramp, char **valuep, int *is_rfc2184_param, int *rfc2184_part)
+header_decode_param (const char **in, char **paramp, char **valuep, int *camel_mime_is_rfc2184_param, int *rfc2184_part)
 {
-	gboolean is_rfc2184_encoded = FALSE;
-	gboolean is_rfc2184 = FALSE;
+	gboolean camel_mime_is_rfc2184_encoded = FALSE;
+	gboolean camel_mime_is_rfc2184 = FALSE;
 	const char *inptr = *in;
 	char *param = NULL;
 	char *value = NULL;
 	
-	*is_rfc2184_param = FALSE;
+	*camel_mime_is_rfc2184_param = FALSE;
 	*rfc2184_part = -1;
 	
-	is_rfc2184 = header_decode_rfc2184_param (&inptr, &param, &is_rfc2184_encoded, rfc2184_part);
+	camel_mime_is_rfc2184 = header_decode_rfc2184_param (&inptr, &param, &camel_mime_is_rfc2184_encoded, rfc2184_part);
 	
 	if (*inptr == '=') {
 		inptr++;
 		value = header_decode_value (&inptr);
 		
-		if (value && is_rfc2184) {
+		if (value && camel_mime_is_rfc2184) {
 			/* We have ourselves an rfc2184 parameter */
 			
 			if (*rfc2184_part == -1) {
@@ -2011,7 +1986,7 @@
 				/* Since we are expecting to find the rest of
 				 * this paramter value later, let our caller know.
 				 */
-				*is_rfc2184_param = TRUE;
+				*camel_mime_is_rfc2184_param = TRUE;
 			}
 		} else if (value && !strncmp (value, "=?", 2)) {
 			/* We have a broken param value that is rfc2047 encoded.
@@ -2234,7 +2209,7 @@
 			inptr++;
 			header_decode_lwsp(&inptr);
 			start = inptr;
-			while (is_dtext(*inptr)) {
+			while (camel_mime_is_dtext(*inptr)) {
 				domain = g_string_append_c(domain, *inptr);
 				inptr++;
 			}
@@ -2943,7 +2918,7 @@
 	const char *inptr = *in;
 	struct _camel_header_param *head = NULL, *tail = NULL;
 	gboolean last_was_rfc2184 = FALSE;
-	gboolean is_rfc2184 = FALSE;
+	gboolean camel_mime_is_rfc2184 = FALSE;
 	
 	header_decode_lwsp (&inptr);
 	
@@ -2954,10 +2929,10 @@
 		
 		inptr++;
 		/* invalid format? */
-		if (header_decode_param (&inptr, &name, &value, &is_rfc2184, &rfc2184_part) != 0)
+		if (header_decode_param (&inptr, &name, &value, &camel_mime_is_rfc2184, &rfc2184_part) != 0)
 			break;
 		
-		if (is_rfc2184 && tail && !strcasecmp (name, tail->name)) {
+		if (camel_mime_is_rfc2184 && tail && !strcasecmp (name, tail->name)) {
 			/* rfc2184 allows a parameter to be broken into multiple parts
 			 * and it looks like we've found one. Append this value to the
 			 * last value.
@@ -2998,7 +2973,7 @@
 			tail = param;
 		}
 		
-		last_was_rfc2184 = is_rfc2184;
+		last_was_rfc2184 = camel_mime_is_rfc2184;
 		
 		header_decode_lwsp (&inptr);
 	}
@@ -3127,7 +3102,7 @@
 		
 		if (c > 127) {
 			g_string_append_printf (out, "%%%c%c", tohex[(c >> 4) & 0xf], tohex[c & 0xf]);
-		} else if (is_lwsp (c) || !(camel_mime_special_table[c] & IS_ESAFE)) {
+		} else if (camel_mime_is_lwsp (c) || !(camel_mime_special_table[c] & CAMEL_MIME_IS_ESAFE)) {
 			g_string_append_printf (out, "%%%c%c", tohex[(c >> 4) & 0xf], tohex[c & 0xf]);
 		} else {
 			g_string_append_c (out, c);
@@ -3170,7 +3145,7 @@
 			char *ch;
 			
 			for (ch = value; *ch; ch++) {
-				if (is_tspecial (*ch) || is_lwsp (*ch))
+				if (camel_mime_is_tspecial (*ch) || camel_mime_is_lwsp (*ch))
 					break;
 			}
 			
@@ -3648,7 +3623,7 @@
 	if (*in == '"')
 		return header_decode_quoted_string(&in);
 	else {
-		for (p = in; *p && !is_lwsp(*p); p++)
+		for (p = in; *p && !camel_mime_is_lwsp(*p); p++)
 			;
 		return g_strndup(in, p - in);
 	}
@@ -3683,10 +3658,10 @@
 	char *name;
 
 	in = header;
-	while (is_fieldname(*in) || *in==':')
+	while (camel_mime_is_fieldname(*in) || *in==':')
 		in++;
 	fieldlen = in-header-1;
-	while (is_lwsp(*in))
+	while (camel_mime_is_lwsp(*in))
 		in++;
 	if (fieldlen == 0 || header[fieldlen] != ':') {
 		printf("Invalid header line: '%s'\n", header);
@@ -4324,10 +4299,10 @@
 	o = out;
 	while ((c = *inptr++)) {
 		if (c == '\n') {
-			if (is_lwsp(*inptr)) {
+			if (camel_mime_is_lwsp(*inptr)) {
 				do {
 					inptr++;
-				} while (is_lwsp(*inptr));
+				} while (camel_mime_is_lwsp(*inptr));
 				*o++ = ' ';
 			} else {
 				*o++ = c;
Index: camel-mime-utils.h
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-mime-utils.h,v
retrieving revision 1.51
diff -u -3 -r1.51 camel-mime-utils.h
--- camel-mime-utils.h	22 Sep 2003 15:00:58 -0000	1.51
+++ camel-mime-utils.h	9 Dec 2003 00:20:02 -0000
@@ -239,6 +239,33 @@
 char *camel_base64_encode_simple (const char *data, size_t len);
 size_t camel_base64_decode_simple (char *data, size_t len);
 
+/* camel ctype type functions for rfc822/rfc2047/other, which are non-locale specific */
+enum {
+	CAMEL_MIME_IS_CTRL		= 1<<0,
+	CAMEL_MIME_IS_LWSP		= 1<<1,
+	CAMEL_MIME_IS_TSPECIAL	= 1<<2,
+	CAMEL_MIME_IS_SPECIAL	= 1<<3,
+	CAMEL_MIME_IS_SPACE	= 1<<4,
+	CAMEL_MIME_IS_DSPECIAL	= 1<<5,
+	CAMEL_MIME_IS_QPSAFE	= 1<<6,
+	CAMEL_MIME_IS_ESAFE	= 1<<7,	/* encoded word safe */
+	CAMEL_MIME_IS_PSAFE	= 1<<8,	/* encoded word in phrase safe */
+};
+
+extern unsigned short camel_mime_special_table[256];
+
+#define camel_mime_is_ctrl(x) ((camel_mime_special_table[(unsigned char)(x)] & CAMEL_MIME_IS_CTRL) != 0)
+#define camel_mime_is_lwsp(x) ((camel_mime_special_table[(unsigned char)(x)] & CAMEL_MIME_IS_LWSP) != 0)
+#define camel_mime_is_tspecial(x) ((camel_mime_special_table[(unsigned char)(x)] & CAMEL_MIME_IS_TSPECIAL) != 0)
+#define camel_mime_is_type(x, t) ((camel_mime_special_table[(unsigned char)(x)] & (t)) != 0)
+#define camel_mime_is_ttoken(x) ((camel_mime_special_table[(unsigned char)(x)] & (CAMEL_MIME_IS_TSPECIAL|CAMEL_MIME_IS_LWSP|CAMEL_MIME_IS_CTRL)) == 0)
+#define camel_mime_is_atom(x) ((camel_mime_special_table[(unsigned char)(x)] & (CAMEL_MIME_IS_SPECIAL|CAMEL_MIME_IS_SPACE|CAMEL_MIME_IS_CTRL)) == 0)
+#define camel_mime_is_dtext(x) ((camel_mime_special_table[(unsigned char)(x)] & CAMEL_MIME_IS_DSPECIAL) == 0)
+#define camel_mime_is_fieldname(x) ((camel_mime_special_table[(unsigned char)(x)] & (CAMEL_MIME_IS_CTRL|CAMEL_MIME_IS_SPACE)) == 0)
+#define camel_mime_is_qpsafe(x) ((camel_mime_special_table[(unsigned char)(x)] & CAMEL_MIME_IS_QPSAFE) != 0)
+#define camel_mime_is_especial(x) ((camel_mime_special_table[(unsigned char)(x)] & CAMEL_MIME_IS_ESPECIAL) != 0)
+#define camel_mime_is_psafe(x) ((camel_mime_special_table[(unsigned char)(x)] & CAMEL_MIME_IS_PSAFE) != 0)
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
Index: camel-url.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-url.c,v
retrieving revision 1.37
diff -u -3 -r1.37 camel-url.c
--- camel-url.c	23 Jul 2003 14:57:20 -0000	1.37
+++ camel-url.c	9 Dec 2003 00:20:06 -0000
@@ -503,7 +503,7 @@
 
 	s = d = (unsigned char *)part;
 	do {
-		if (*s == '%' && s[1] && s[2]) {
+		if (*s == '%' && isxdigit(s[1]) && isxdigit(s[2])) {
 			*d++ = (XDIGIT (s[1]) << 4) + XDIGIT (s[2]);
 			s += 2;
 		} else
Index: providers/imap/camel-imap-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/providers/imap/camel-imap-utils.c,v
retrieving revision 1.69
diff -u -3 -r1.69 camel-imap-utils.c
--- providers/imap/camel-imap-utils.c	18 Sep 2003 17:06:35 -0000	1.69
+++ providers/imap/camel-imap-utils.c	9 Dec 2003 00:20:09 -0000
@@ -552,7 +552,7 @@
 /* 40 */1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 /* 50 */1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1,
 /* 60 */1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-/* 70 */1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0,
+/* 70 */1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0,
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
Index: providers/local/camel-local-folder.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/providers/local/camel-local-folder.c,v
retrieving revision 1.41
diff -u -3 -r1.41 camel-local-folder.c
--- providers/local/camel-local-folder.c	21 Oct 2003 18:51:15 -0000	1.41
+++ providers/local/camel-local-folder.c	9 Dec 2003 00:20:16 -0000
@@ -440,12 +440,10 @@
 			/* FIXME: implement */
 			/* TODO: When turning on (off?) the index, we want to launch a task for it,
 			   and make sure we dont have multiple tasks doing the same job */
-			printf("setting folder indexing %s\n", arg->ca_int?"on":"off");
 			if (arg->ca_int)
 				((CamelLocalFolder *)object)->flags |= CAMEL_STORE_FOLDER_BODY_INDEX;
 			else
 				((CamelLocalFolder *)object)->flags &= ~CAMEL_STORE_FOLDER_BODY_INDEX;
-			printf("setv:'%s' flags %08x\n", ((CamelFolder *)object)->full_name, ((CamelLocalFolder *)object)->flags);
 			break;
 		default:
 			continue;
Index: providers/smtp/camel-smtp-transport.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/providers/smtp/camel-smtp-transport.c,v
retrieving revision 1.149
diff -u -3 -r1.149 camel-smtp-transport.c
--- providers/smtp/camel-smtp-transport.c	6 Nov 2003 16:26:26 -0000	1.149
+++ providers/smtp/camel-smtp-transport.c	9 Dec 2003 00:20:24 -0000
@@ -710,17 +710,22 @@
 	
 	cia = CAMEL_INTERNET_ADDRESS (recipients);
 	for (i = 0; i < len; i++) {
+		char *enc;
+
 		if (!camel_internet_address_get (cia, i, NULL, &addr)) {
 			camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
 					     _("Cannot send message: one or more invalid recipients"));
 			camel_operation_end (NULL);
 			return FALSE;
 		}
-		
-		if (!smtp_rcpt (smtp_transport, addr, ex)) {
+
+		enc = camel_internet_address_encode_address(NULL, NULL, addr);
+		if (!smtp_rcpt (smtp_transport, enc, ex)) {
+			g_free(enc);
 			camel_operation_end (NULL);
 			return FALSE;
 		}
+		g_free(enc);
 	}
 	
 	if (!smtp_data (smtp_transport, message, ex)) {


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