From: Timo Sirainen Date: Sat, 21 Jun 2008 06:21:51 +0000 (+0300) Subject: Added imap_dquote_append(). X-Git-Tag: 1.2.alpha1~245 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6764705326c7187d703b784b8e86083c08363549;p=thirdparty%2Fdovecot%2Fcore.git Added imap_dquote_append(). --HG-- branch : HEAD --- diff --git a/src/lib-imap/imap-quote.c b/src/lib-imap/imap-quote.c index 8499bc9efd..d25b8bc355 100644 --- a/src/lib-imap/imap-quote.c +++ b/src/lib-imap/imap-quote.c @@ -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, '"'); +} diff --git a/src/lib-imap/imap-quote.h b/src/lib-imap/imap-quote.h index 944b577f80..7ee5afa290 100644 --- a/src/lib-imap/imap-quote.h +++ b/src/lib-imap/imap-quote.h @@ -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