commit efab63fb8e14aaa38c6dede11ea36ab4f46f6572
parent 9169ee8fd8eb774642b371b58df81a783f355f8d
Author: Oswald Buddenhagen <ossi@users.sf.net>
Date: Mon, 23 May 2022 12:04:57 +0200
enable UTF-8 on servers with RFC6855 support
note that this is a somewhat sloppy implementation, as it simply
assumes that the local system uses UTF-8 - that seems reasonable
nowadays.
Diffstat:
2 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/NEWS b/NEWS
@@ -19,6 +19,8 @@ Made the Channel side to expire with MaxMessages configurable.
MaxMessages and MaxSize can be used together now.
+Added support for IMAP mailbox names with non-ASCII characters.
+
The unfiltered list of mailboxes in each Store can be printed now.
A proper summary is now printed prior to exiting.
diff --git a/src/drv_imap.c b/src/drv_imap.c
@@ -286,6 +286,8 @@ enum CAPABILITY {
LITERALMINUS,
MOVE,
NAMESPACE,
+ UTF8_ACCEPT,
+ UTF8_ONLY,
COMPRESS_DEFLATE
};
@@ -306,6 +308,8 @@ static const struct {
{ "LITERAL-", 8 },
{ "MOVE", 4 },
{ "NAMESPACE", 9 },
+ { "UTF8=ACCEPT", 11 },
+ { "UTF8=ONLY", 9 },
{ "COMPRESS=DEFLATE", 16 },
};
@@ -2090,6 +2094,8 @@ static void imap_open_store_compress( imap_store_t * );
#ifdef HAVE_LIBZ
static void imap_open_store_compress_p2( imap_store_t *, imap_cmd_t *, int );
#endif
+static void imap_open_store_enable_utf8( imap_store_t * );
+static void imap_open_store_enable_utf8_p2( imap_store_t *, imap_cmd_t *, int );
static void imap_open_store_namespace( imap_store_t * );
static void imap_open_store_namespace_p2( imap_store_t *, imap_cmd_t *, int );
static void imap_open_store_namespace2( imap_store_t * );
@@ -2737,7 +2743,7 @@ imap_open_store_compress( imap_store_t *ctx )
return;
}
#endif
- imap_open_store_namespace( ctx );
+ imap_open_store_enable_utf8( ctx );
}
#ifdef HAVE_LIBZ
@@ -2746,15 +2752,36 @@ imap_open_store_compress_p2( imap_store_t *ctx, imap_cmd_t *cmd ATTR_UNUSED, int
{
if (response == RESP_NO) {
/* We already reported an error, but it's not fatal to us. */
- imap_open_store_namespace( ctx );
+ imap_open_store_enable_utf8( ctx );
} else if (response == RESP_OK) {
socket_start_deflate( &ctx->conn );
- imap_open_store_namespace( ctx );
+ imap_open_store_enable_utf8( ctx );
}
}
#endif
static void
+imap_open_store_enable_utf8( imap_store_t *ctx )
+{
+ if (CAP(UTF8_ACCEPT) || CAP(UTF8_ONLY)) {
+ // We just assume that a server that announces UTF8= also supports ENABLE.
+ imap_exec( ctx, NULL, imap_open_store_enable_utf8_p2, "ENABLE UTF8=ACCEPT" );
+ } else {
+ imap_open_store_namespace( ctx );
+ }
+}
+
+static void
+imap_open_store_enable_utf8_p2( imap_store_t *ctx, imap_cmd_t *cmd ATTR_UNUSED, int response )
+{
+ if (response == RESP_NO) {
+ imap_open_store_bail( ctx, FAIL_FINAL );
+ } else if (response == RESP_OK) {
+ imap_open_store_namespace( ctx );
+ }
+}
+
+static void
imap_open_store_namespace( imap_store_t *ctx )
{
imap_store_conf_t *cfg = ctx->conf;