~ubuntu-branches/ubuntu/utopic/dovecot/utopic

« back to all changes in this revision

Viewing changes to debian/patches/utf8-namespace.patch

  • Committer: Package Import Robot
  • Author(s): James Page, James Page, Ante Karamatic
  • Date: 2013-02-11 12:41:24 UTC
  • mfrom: (4.1.33 sid)
  • Revision ID: package-import@ubuntu.com-20130211124124-v7bdegzftlhw7yfr
Tags: 1:2.1.7-7ubuntu1
[ James Page ]
* Merge from Debian unstable (LP: #1117613, #1075456), remaining changes:
  + Add mail-stack-delivery package:
    - Update d/rules
    - d/control: convert existing dovecot-postfix package to a dummy
      package and add new mail-stack-delivery package.
    - Update maintainer scripts.
    - Rename d/dovecot-postfix.* to debian/mail-stack-delivery.*
    - d/mail-stack-delivery.preinst: Move previously installed backups and
      config files to a new package namespace.
    - d/mail-stack-delivery.prerm: Added to handle downgrades.
  + Use Snakeoil SSL certificates by default:
    - d/control: Depend on ssl-cert.
    - d/dovecot-core.postinst: Relax grep for SSL_* a bit.
  + Add autopkgtest to debian/tests/*.
  + Add ufw integration:
    - d/dovecot-core.ufw.profile: new ufw profile.
    - d/rules: install profile in dovecot-core.
    - d/control: dovecot-core - suggest ufw.
  + d/dovecot-core.dirs: Added usr/share/doc/dovecot-core
  + Add apport hook:
    - d/rules, d/source_dovecot.py
  + Add upstart job:
    - d/rules, d/dovecot-core.dovecot.upstart, d/control,
      d/dovecot-core.dirs, dovecot-imapd.{postrm, postinst, prerm},
      d/dovecot-pop3d.{postinst, postrm, prerm}.
      d/mail-stack-deliver.postinst: Convert init script to upstart.
  + d/control: Added Pre-Depends: dpkg (>= 1.15.6) to dovecot-dbg to support
    xz compression in Ubuntu.
  + d/control: Demote dovecot-common Recommends: to Suggests: to prevent
    install of extra packages on upgrade.
  + d/patches/dovecot-drac.patch: Updated with version for dovecot >= 2.0.0.
* Dropped changes, included in Debian:
  + d/{control,rules}: enable PIE hardening.
  + d/control: Drop B-D on systemd.
* d/p/mail-stack-delivery.postinst: Updated to ensure that configured SSL
  cert and key locations are used when configuring postfix, sorted out
  formatting.
* d/p/dovecot-core.postinst: Create compat links to old style, existing
  SSL cert and key if found.
* d/rules: Don't pass hardening flags for DRAC plugin.
* d/dovecot-{pop3d,imapd}.prerm: Re-sync with Debian.
* d/dovecot-core.lintian-overrides: Drop override for DRAC plugin as not
  required in Ubuntu.
* d/01-mail-stack-delivery: Renamed 99-mail-stack-delivery to ensure that
  the mail-stack-delivery configuration overrides configuration options
  set elsewhere, updated with new cert/key file locations.

[ Ante Karamatic ]
* Change configuration file for LDA on new installs and upgrades
  (LP: #671065).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From: Jaldhar H. Vyas <jaldhar@debian.org>
 
2
Date: Sun, 30 Sep 2012 11:31:43 -0400
 
3
Subject: backport of 2.1.8 fixes for UTF-8 namespaces
 
4
Bug: #685841
 
5
Description: Fixes handling of UTF-8 namespace prefixes
 
6
 # HG changeset patch
 
7
 # User Timo Sirainen <tss@iki.fi>
 
8
 # Date 1345751816 -10800
 
9
 # Node ID ade94fde249e1379af55df62c47ad98e19ddb935
 
10
 # Parent  565605200989dd5a81b8358a13420a4d7b30b33c
 
11
 imap: Fixes to handling UTF-8 namespace prefixes
 
12
Origin: http://hg.dovecot.org/dovecot-2.1
 
13
---
 
14
diff -r 565605200989 -r ade94fde249e src/imap/cmd-list.c
 
15
--- a/src/imap/cmd-list.c       Thu Aug 23 22:33:23 2012 +0300
 
16
+++ b/src/imap/cmd-list.c       Thu Aug 23 22:56:56 2012 +0300
 
17
@@ -230,6 +230,19 @@
 
18
        return ret;
 
19
 }
 
20
 
 
21
+static const char *ns_prefix_mutf7(struct mail_namespace *ns)
 
22
+{
 
23
+       string_t *str;
 
24
+
 
25
+       if (*ns->prefix == '\0')
 
26
+               return "";
 
27
+
 
28
+       str = t_str_new(64);
 
29
+       if (imap_utf8_to_utf7(ns->prefix, str) < 0)
 
30
+               i_panic("Namespace prefix not UTF-8: %s", ns->prefix);
 
31
+       return str_c(str);
 
32
+}
 
33
+
 
34
 static const char *ns_get_listed_prefix(struct cmd_list_context *ctx)
 
35
 {
 
36
        struct imap_match_glob *glob;
 
37
@@ -285,7 +298,7 @@
 
38
        unsigned int len;
 
39
        enum mailbox_info_flags flags;
 
40
        const char *name;
 
41
-       string_t *str;
 
42
+       string_t *str, *mutf7_name;
 
43
        bool same_ns, ends_with_sep;
 
44
        char ns_sep = mail_namespace_get_sep(ctx->ns);
 
45
 
 
46
@@ -364,7 +377,11 @@
 
47
        str_append(str, ") ");
 
48
        list_reply_append_ns_sep_param(str, ns_sep);
 
49
        str_append_c(str, ' ');
 
50
-       imap_quote_append_string(str, name, FALSE);
 
51
+
 
52
+       mutf7_name = t_str_new(64);
 
53
+       if (imap_utf8_to_utf7(name, mutf7_name) < 0)
 
54
+               i_panic("Namespace prefix not UTF-8: %s", name);
 
55
+       imap_quote_append_string(str, str_c(mutf7_name), FALSE);
 
56
        mailbox_childinfo2str(ctx, str, flags);
 
57
 
 
58
        client_send_line(ctx->cmd->client, str_c(str));
 
59
@@ -870,7 +887,7 @@
 
60
           Otherwise we'll emulate UW-IMAP behavior. */
 
61
        ns = mail_namespace_find_visible(client->user->namespaces, ref);
 
62
        if (ns != NULL) {
 
63
-               ns_prefix = ns->prefix;
 
64
+               ns_prefix = ns_prefix_mutf7(ns);
 
65
                ns_sep = mail_namespace_get_sep(ns);
 
66
        } else {
 
67
                ns_prefix = "";
 
68
@@ -938,6 +955,10 @@
 
69
                return TRUE;
 
70
        }
 
71
        str = t_str_new(64);
 
72
+       if (imap_utf7_to_utf8(ctx->ref, str) == 0)
 
73
+               ctx->ref = p_strdup(cmd->pool, str_c(str));
 
74
+       str_truncate(str, 0);
 
75
+
 
76
        if (imap_arg_get_list_full(&args[1], &list_args, &arg_count)) {
 
77
                ctx->used_listext = TRUE;
 
78
                /* convert pattern list to string array */
 
79
diff -r 565605200989 -r ade94fde249e src/imap/cmd-namespace.c
 
80
--- a/src/imap/cmd-namespace.c  Thu Aug 23 22:33:23 2012 +0300
 
81
+++ b/src/imap/cmd-namespace.c  Thu Aug 23 22:56:56 2012 +0300
 
82
@@ -2,6 +2,7 @@
 
83
 
 
84
 #include "imap-common.h"
 
85
 #include "str.h"
 
86
+#include "imap-utf7.h"
 
87
 #include "imap-quote.h"
 
88
 #include "imap-commands.h"
 
89
 #include "mail-namespace.h"
 
90
@@ -9,6 +10,7 @@
 
91
 static void list_namespaces(struct mail_namespace *ns,
 
92
                            enum namespace_type type, string_t *str)
 
93
 {
 
94
+       string_t *mutf7_prefix = t_str_new(64);
 
95
        char ns_sep;
 
96
        bool found = FALSE;
 
97
 
 
98
@@ -21,7 +23,14 @@
 
99
                        }
 
100
                        ns_sep = mail_namespace_get_sep(ns);
 
101
                        str_append_c(str, '(');
 
102
-                       imap_quote_append_string(str, ns->prefix, FALSE);
 
103
+
 
104
+                       str_truncate(mutf7_prefix, 0);
 
105
+                       if (imap_utf8_to_utf7(ns->prefix, mutf7_prefix) < 0) {
 
106
+                               i_panic("LIST: Namespace prefix not UTF-8: %s",
 
107
+                                       ns->prefix);
 
108
+                       }
 
109
+
 
110
+                       imap_quote_append_string(str, str_c(mutf7_prefix), FALSE);
 
111
                        str_append(str, " \"");
 
112
                        if (ns_sep == '\\')
 
113
                                str_append_c(str, '\\');
 
114
diff -r 565605200989 -r ade94fde249e src/imap/imap-commands-util.c
 
115
--- a/src/imap/imap-commands-util.c     Thu Aug 23 22:33:23 2012 +0300
 
116
+++ b/src/imap/imap-commands-util.c     Thu Aug 23 22:56:56 2012 +0300
 
117
@@ -19,10 +19,15 @@
 
118
 {
 
119
        struct mail_namespace *namespaces = cmd->client->user->namespaces;
 
120
        struct mail_namespace *ns;
 
121
-       unsigned int name_len;
 
122
        string_t *utf8_name;
 
123
 
 
124
-       ns = mail_namespace_find(namespaces, *mailbox);
 
125
+       utf8_name = t_str_new(64);
 
126
+       if (imap_utf7_to_utf8(*mailbox, utf8_name) < 0) {
 
127
+               client_send_tagline(cmd, "NO Mailbox name is not valid mUTF-7");
 
128
+               return NULL;
 
129
+       }
 
130
+
 
131
+       ns = mail_namespace_find(namespaces, str_c(utf8_name));
 
132
        if (ns == NULL) {
 
133
                client_send_tagline(cmd, t_strdup_printf(
 
134
                        "NO Client tried to access nonexistent namespace. "
 
135
@@ -31,20 +36,14 @@
 
136
                return NULL;
 
137
        }
 
138
 
 
139
-       name_len = strlen(*mailbox);
 
140
        if ((cmd->client->set->parsed_workarounds &
 
141
                        WORKAROUND_TB_EXTRA_MAILBOX_SEP) != 0 &&
 
142
-           name_len > 0 &&
 
143
-           (*mailbox)[name_len-1] == mail_namespace_get_sep(ns)) {
 
144
+           str_len(utf8_name) > 0 &&
 
145
+           str_c(utf8_name)[str_len(utf8_name)-1] == mail_namespace_get_sep(ns)) {
 
146
                /* drop the extra trailing hierarchy separator */
 
147
-               *mailbox = t_strndup(*mailbox, name_len-1);
 
148
+               str_truncate(utf8_name, str_len(utf8_name)-1);
 
149
        }
 
150
 
 
151
-       utf8_name = t_str_new(64);
 
152
-       if (imap_utf7_to_utf8(*mailbox, utf8_name) < 0) {
 
153
-               client_send_tagline(cmd, "NO Mailbox name is not valid mUTF-7");
 
154
-               return NULL;
 
155
-       }
 
156
        *mailbox = str_c(utf8_name);
 
157
        return ns;
 
158
 }
 
159