Index: dovecot/src/lib-sql/driver-sqlite.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-sql/driver-sqlite.c,v
retrieving revision 1.5.2.1
diff -u -r1.5.2.1 driver-sqlite.c
--- dovecot/src/lib-sql/driver-sqlite.c	31 May 2006 11:02:45 -0000	1.5.2.1
+++ dovecot/src/lib-sql/driver-sqlite.c	25 Jun 2006 12:53:48 -0000
@@ -92,7 +92,24 @@
 static char *driver_sqlite_escape_string(struct sql_db *_db __attr_unused__,
 					 const char *string)
 {
-	return t_strdup_noconst(str_escape(string));
+	size_t newlen = 0;
+	char *c, *newstr;
+
+	/* check if escaping is needed */
+	if (index(string, '\'') == NULL)
+		return string;
+
+	/* escape ' */
+	newstr = t_buffer_get(strlen(string) * 2 + 1);
+	for (c=string; *c != '\0'; ++c) {
+		newstr[newlen++] = *c;
+		if (*c == '\'')
+			newstr[newlen++] = *c;
+	}
+	newstr[newlen] = '\0';
+	t_buffer_alloc(newlen + 1);
+
+	return newstr;
 }

 static void driver_sqlite_exec(struct sql_db *_db, const char *query)
