evolution-data-server r8778 - trunk/camel/providers/imap4



Author: fejj
Date: Sat May 10 16:33:08 2008
New Revision: 8778
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=8778&view=rev

Log:
2008-05-10  Jeffrey Stedfast  <fejj novell com>

	* camel-imap4-command.c (imap4_command_append_string): Fixed a
	FIXME by properly escaping QSTRING specials.



Modified:
   trunk/camel/providers/imap4/ChangeLog
   trunk/camel/providers/imap4/camel-imap4-command.c

Modified: trunk/camel/providers/imap4/camel-imap4-command.c
==============================================================================
--- trunk/camel/providers/imap4/camel-imap4-command.c	(original)
+++ trunk/camel/providers/imap4/camel-imap4-command.c	Sat May 10 16:33:08 2008
@@ -144,6 +144,8 @@
 {
 	CamelIMAP4CommandPart *part;
 	CamelIMAP4Literal *literal;
+	register const char *inptr;
+	const char *start;
 	
 	switch (imap4_string_get_type (string)) {
 	case IMAP4_STRING_ATOM:
@@ -152,8 +154,25 @@
 		break;
 	case IMAP4_STRING_QSTRING:
 		/* we need to quote the string */
-		/* FIXME: need to escape stuff */
-		g_string_append_printf (str, "\"%s\"", string);
+		g_string_append_c (str, '"');
+		
+		inptr = string;
+		while (*inptr) {
+			start = string;
+			while (*inptr && *inptr != '\\' && *inptr != '"')
+				inptr++;
+			
+			if (inptr > start)
+				g_string_append_len (str, start, inptr - start);
+			
+			if (*inptr != '\0') {
+				g_string_append_c (str, '\\');
+				g_string_append_c (str, *inptr);
+				inptr++;
+			}
+		}
+		
+		g_string_append_c (str, '"');
 		break;
 	case IMAP4_STRING_LITERAL:
 		if (engine->capa & CAMEL_IMAP4_CAPABILITY_LITERALPLUS) {



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