Mercurial > dovecot > core-2.2
view src/lib-charset/charset-utf8-only.c @ 23017:c1d36f2575c7 default tip
lib-imap: Fix "Don't accept strings with NULs" cherry-pick
author | Timo Sirainen <timo.sirainen@open-xchange.com> |
---|---|
date | Thu, 29 Aug 2019 09:55:25 +0300 |
parents | 01666acde1a8 |
children |
line wrap: on
line source
/* Copyright (c) 2002-2017 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "charset-utf8-private.h" #ifndef HAVE_ICONV struct charset_translation { normalizer_func_t *normalizer; }; static int utf8only_charset_to_utf8_begin(const char *charset, normalizer_func_t *normalizer, struct charset_translation **t_r) { struct charset_translation *t; if (!charset_is_utf8(charset)) { /* no support for charsets that need translation */ return -1; } t = i_new(struct charset_translation, 1); t->normalizer = normalizer; *t_r = t; return 0; } static void utf8only_charset_to_utf8_end(struct charset_translation *t) { i_free(t); } static void utf8only_charset_to_utf8_reset(struct charset_translation *t ATTR_UNUSED) { } static enum charset_result utf8only_charset_to_utf8(struct charset_translation *t, const unsigned char *src, size_t *src_size, buffer_t *dest) { return charset_utf8_to_utf8(t->normalizer, src, src_size, dest); } const struct charset_utf8_vfuncs charset_utf8only = { .to_utf8_begin = utf8only_charset_to_utf8_begin, .to_utf8_end = utf8only_charset_to_utf8_end, .to_utf8_reset = utf8only_charset_to_utf8_reset, .to_utf8 = utf8only_charset_to_utf8, }; #endif