~ubuntu-branches/ubuntu/wily/dovecot/wily

« back to all changes in this revision

Viewing changes to src/dict/dict-commands.c

  • Committer: Package Import Robot
  • Author(s): Jelmer Vernooij
  • Date: 2015-05-24 15:01:19 UTC
  • mto: (4.1.53 sid)
  • mto: This revision was merged to the branch mainline in revision 102.
  • Revision ID: package-import@ubuntu.com-20150524150119-hsh6cbr1fqseapga
Tags: upstream-2.2.18
ImportĀ upstreamĀ versionĀ 2.2.18

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
#include "array.h"
5
5
#include "ostream.h"
6
6
#include "str.h"
 
7
#include "strescape.h"
7
8
#include "dict-client.h"
8
9
#include "dict-settings.h"
9
10
#include "dict-connection.h"
33
34
        ret = dict_lookup(conn->dict, pool_datastack_create(), line, &value);
34
35
        if (ret > 0) {
35
36
                reply = t_strdup_printf("%c%s\n",
36
 
                                        DICT_PROTOCOL_REPLY_OK, value);
 
37
                        DICT_PROTOCOL_REPLY_OK, str_tabescape(value));
37
38
                o_stream_nsend_str(conn->output, reply);
38
39
        } else {
39
40
                reply = t_strdup_printf("%c\n", ret == 0 ?
53
54
        o_stream_cork(conn->output);
54
55
        while (dict_iterate(conn->iter_ctx, &key, &value)) {
55
56
                str_truncate(str, 0);
56
 
                str_printfa(str, "%c%s\t", DICT_PROTOCOL_REPLY_OK, key);
 
57
                str_append_c(str, DICT_PROTOCOL_REPLY_OK);
 
58
                str_append_tabescaped(str, key);
 
59
                str_append_c(str, '\t');
57
60
                if ((conn->iter_flags & DICT_ITERATE_FLAG_NO_VALUE) == 0)
58
 
                        str_append(str, value);
 
61
                        str_append_tabescaped(str, value);
59
62
                str_append_c(str, '\n');
60
63
                o_stream_nsend(conn->output, str_data(str), str_len(str));
61
64
 
92
95
                return -1;
93
96
        }
94
97
 
95
 
        args = t_strsplit_tab(line);
 
98
        args = t_strsplit_tabescaped(line);
96
99
        if (str_array_length(args) < 2 ||
97
100
            str_to_uint(args[0], &flags) < 0) {
98
101
                i_error("dict client: ITERATE: broken input");
275
278
        const char *const *args;
276
279
 
277
280
        /* <id> <key> <value> */
278
 
        args = t_strsplit_tab(line);
 
281
        args = t_strsplit_tabescaped(line);
279
282
        if (str_array_length(args) != 3) {
280
283
                i_error("dict client: SET: broken input");
281
284
                return -1;
294
297
        const char *const *args;
295
298
 
296
299
        /* <id> <key> */
297
 
        args = t_strsplit_tab(line);
 
300
        args = t_strsplit_tabescaped(line);
298
301
        if (str_array_length(args) != 2) {
299
302
                i_error("dict client: UNSET: broken input");
300
303
                return -1;
313
316
        const char *const *args;
314
317
 
315
318
        /* <id> <key> <value> */
316
 
        args = t_strsplit_tab(line);
 
319
        args = t_strsplit_tabescaped(line);
317
320
        if (str_array_length(args) != 3) {
318
321
                i_error("dict client: APPEND: broken input");
319
322
                return -1;
333
336
        long long diff;
334
337
 
335
338
        /* <id> <key> <diff> */
336
 
        args = t_strsplit_tab(line);
 
339
        args = t_strsplit_tabescaped(line);
337
340
        if (str_array_length(args) != 3 ||
338
341
            str_to_llong(args[2], &diff) < 0) {
339
342
                i_error("dict client: ATOMIC_INC: broken input");