From 6764705326c7187d703b784b8e86083c08363549 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sat, 21 Jun 2008 09:21:51 +0300 Subject: [PATCH] Added imap_dquote_append(). --HG-- branch : HEAD --- src/lib-imap/imap-quote.c | 23 +++++++++++++++++++++++ src/lib-imap/imap-quote.h | 3 +++ 2 files changed, 26 insertions(+) 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 -- 2.47.3