[evolution-data-server/gnome-3-30] I#40 - [IMAPx] Support RFC 6855 (IMAP Support for UTF-8) ][
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-3-30] I#40 - [IMAPx] Support RFC 6855 (IMAP Support for UTF-8) ][
- Date: Fri, 5 Oct 2018 07:27:35 +0000 (UTC)
commit 25693eacf1b5cd2be66705d7fa652ca599fab781
Author: Milan Crha <mcrha redhat com>
Date: Fri Oct 5 09:19:22 2018 +0200
I#40 - [IMAPx] Support RFC 6855 (IMAP Support for UTF-8) ][
Related to https://gitlab.gnome.org/GNOME/evolution-data-server/issues/40
src/camel/providers/imapx/camel-imapx-command.c | 28 +++++++++++++++++++------
src/camel/providers/imapx/camel-imapx-server.c | 20 ++++++++++++++++--
src/camel/providers/imapx/camel-imapx-server.h | 2 ++
3 files changed, 42 insertions(+), 8 deletions(-)
---
diff --git a/src/camel/providers/imapx/camel-imapx-command.c b/src/camel/providers/imapx/camel-imapx-command.c
index dffa8f017..acd2b1084 100644
--- a/src/camel/providers/imapx/camel-imapx-command.c
+++ b/src/camel/providers/imapx/camel-imapx-command.c
@@ -198,6 +198,7 @@ camel_imapx_command_addv (CamelIMAPXCommand *ic,
GString *buffer;
gchar *utf7_name = NULL;
const gchar *name;
+ gboolean use_utf8_string = FALSE;
g_return_if_fail (CAMEL_IS_IMAPX_COMMAND (ic));
@@ -265,14 +266,19 @@ camel_imapx_command_addv (CamelIMAPXCommand *ic,
break;
case 's': /* simple string */
s = va_arg (ap, gchar *);
+ use_utf8_string = FALSE;
c (camel_imapx_server_get_tagprefix (ic->is), "got string '%s'\n",
g_str_has_prefix (format, "LOGIN") ? "***" : s);
output_string:
if (s && *s) {
guchar mask = imapx_is_mask (s);
- if (mask & IMAPX_TYPE_ATOM_CHAR)
+ if (use_utf8_string && !(mask & IMAPX_TYPE_ATOM_CHAR)) {
+ g_string_append_c (buffer, '"');
+ g_string_append (buffer, s);
+ g_string_append_c (buffer, '"');
+ } else if (mask & IMAPX_TYPE_ATOM_CHAR) {
g_string_append (buffer, s);
- else if (mask & IMAPX_TYPE_TEXT_CHAR) {
+ } else if (mask & IMAPX_TYPE_TEXT_CHAR) {
gboolean is_gmail_search = FALSE;
g_string_append_c (buffer, '"');
@@ -312,13 +318,23 @@ camel_imapx_command_addv (CamelIMAPXCommand *ic,
case 'M': /* CamelIMAPXMailbox */
mailbox = va_arg (ap, CamelIMAPXMailbox *);
name = camel_imapx_mailbox_get_name (mailbox);
- utf7_name = camel_utf8_utf7 (name);
- s = utf7_name;
+ if (camel_imapx_server_get_utf8_accept (ic->is)) {
+ use_utf8_string = TRUE;
+ s = (gchar *) name;
+ } else {
+ utf7_name = camel_utf8_utf7 (name);
+ s = utf7_name;
+ }
goto output_string;
case 'm': /* UTF-8 mailbox name */
name = va_arg (ap, gchar *);
- utf7_name = camel_utf8_utf7 (name);
- s = utf7_name;
+ if (camel_imapx_server_get_utf8_accept (ic->is)) {
+ use_utf8_string = TRUE;
+ s = (gchar *) name;
+ } else {
+ utf7_name = camel_utf8_utf7 (name);
+ s = utf7_name;
+ }
goto output_string;
case 'F': /* IMAP flags set */
f = va_arg (ap, guint32);
diff --git a/src/camel/providers/imapx/camel-imapx-server.c b/src/camel/providers/imapx/camel-imapx-server.c
index 831c05a27..c42282daa 100644
--- a/src/camel/providers/imapx/camel-imapx-server.c
+++ b/src/camel/providers/imapx/camel-imapx-server.c
@@ -320,6 +320,8 @@ struct _CamelIMAPXServerPrivate {
GHashTable *list_responses_hash; /* ghar *mailbox-name ~> CamelIMAPXListResponse *, both owned by
list_responses */
GSList *list_responses;
GSList *lsub_responses;
+
+ gboolean utf8_accept; /* RFC 6855 */
};
enum {
@@ -3339,6 +3341,8 @@ preauthed:
/* Fetch namespaces (if supported). */
g_mutex_lock (&is->priv->stream_lock);
+ is->priv->utf8_accept = FALSE;
+
/* RFC 6855 */
if (CAMEL_IMAPX_HAVE_CAPABILITY (is->priv->cinfo, UTF8_ACCEPT) ||
CAMEL_IMAPX_HAVE_CAPABILITY (is->priv->cinfo, UTF8_ONLY)) {
@@ -3356,6 +3360,8 @@ preauthed:
}
g_mutex_lock (&is->priv->stream_lock);
+
+ is->priv->utf8_accept = TRUE;
}
if (CAMEL_IMAPX_HAVE_CAPABILITY (is->priv->cinfo, NAMESPACE)) {
@@ -6592,8 +6598,10 @@ camel_imapx_server_uid_search_sync (CamelIMAPXServer *is,
if (!success)
return FALSE;
- for (ii = 0; !need_charset && words && words[ii]; ii++) {
- need_charset = !imapx_util_all_is_ascii (words[ii]);
+ if (!camel_imapx_server_get_utf8_accept (is)) {
+ for (ii = 0; !need_charset && words && words[ii]; ii++) {
+ need_charset = !imapx_util_all_is_ascii (words[ii]);
+ }
}
ic = camel_imapx_command_new (is, CAMEL_IMAPX_JOB_UID_SEARCH, "UID SEARCH");
@@ -7181,6 +7189,14 @@ camel_imapx_server_set_tagprefix (CamelIMAPXServer *is,
is->priv->tagprefix = tagprefix;
}
+gboolean
+camel_imapx_server_get_utf8_accept (CamelIMAPXServer *is)
+{
+ g_return_val_if_fail (CAMEL_IS_IMAPX_SERVER (is), FALSE);
+
+ return is->priv->utf8_accept;
+}
+
CamelIMAPXCommand *
camel_imapx_server_ref_current_command (CamelIMAPXServer *is)
{
diff --git a/src/camel/providers/imapx/camel-imapx-server.h b/src/camel/providers/imapx/camel-imapx-server.h
index c8f7cfe75..fb937b17c 100644
--- a/src/camel/providers/imapx/camel-imapx-server.h
+++ b/src/camel/providers/imapx/camel-imapx-server.h
@@ -147,6 +147,8 @@ gchar camel_imapx_server_get_tagprefix
void camel_imapx_server_set_tagprefix
(CamelIMAPXServer *is,
gchar tagprefix);
+gboolean camel_imapx_server_get_utf8_accept
+ (CamelIMAPXServer *is);
CamelIMAPXCommand *
camel_imapx_server_ref_current_command
(CamelIMAPXServer *is);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]