]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Added imap_dquote_append().
authorTimo Sirainen <tss@iki.fi>
Sat, 21 Jun 2008 06:21:51 +0000 (09:21 +0300)
committerTimo Sirainen <tss@iki.fi>
Sat, 21 Jun 2008 06:21:51 +0000 (09:21 +0300)
--HG--
branch : HEAD

src/lib-imap/imap-quote.c
src/lib-imap/imap-quote.h

index 8499bc9efda5217c409ee1c087c376a1361d467f..d25b8bc3553a592765a9a6f22a8381175a22db0f 100644 (file)
@@ -108,3 +108,26 @@ const char *imap_quote(pool_t pool, const unsigned char *value,
                t_pop();
        return ret;
 }
+
+void imap_dquote_append(string_t *dest, const char *src)
+{
+       str_append_c(dest, '"');
+       for (; *src != '\0'; src++) {
+               switch (*src) {
+               case '"':
+               case '\\':
+                       str_append_c(dest, '\\');
+                       str_append_c(dest, *src);
+                       break;
+               default:
+                       if ((unsigned char)*src >= 0x80) {
+                               /* 8bit input not allowed in dquotes */
+                               break;
+                       }
+
+                       str_append_c(dest, *src);
+                       break;
+               }
+       }
+       str_append_c(dest, '"');
+}
index 944b577f808bcd34658da389b23f1acbdc2337aa..7ee5afa290b9028db15750fd67592c6ef374ed30 100644 (file)
@@ -15,4 +15,7 @@ void imap_quote_append(string_t *str, const unsigned char *value,
        imap_quote_append(str, (const unsigned char *)(value), \
                          (size_t)-1, compress_lwsp)
 
+/* Append data to destination string quoted using "". */
+void imap_dquote_append(string_t *dest, const char *src);
+
 #endif