quoted-printable.c revision e8ee95581992b8f7d734981550018d7ecdaae6b8
e59faf65ce864fe95dc00f5d52b8323cdbd0608aTimo Sirainen/* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */
95a1a5195d56f3cf5d1e529aad668f87ad3b979bTimo Sirainenqp_is_end_of_line(const unsigned char *src, size_t *src_pos, size_t size)
4bc96ba6f1d67a90a75fa131bcd2cd508ea5a05aTimo Sirainen for (i++; i < size; i++) {
029cfcdce65b284d5230adf1c920a5f526b03b5cTimo Sirainen if (QP_IS_TRAILING_SPACE(src[i]) || src[i] == '\r')
90c23747727c85f80e4e8eed7968f0edbeac7ac5Timo Sirainenquoted_printable_decode_full(const unsigned char *src, size_t src_size,
90c23747727c85f80e4e8eed7968f0edbeac7ac5Timo Sirainen for (src_pos = 0; src_pos < src_size; src_pos++) {
90c23747727c85f80e4e8eed7968f0edbeac7ac5Timo Sirainen if (src[src_pos] != '=' && src[src_pos] != '\n')
4bc96ba6f1d67a90a75fa131bcd2cd508ea5a05aTimo Sirainen /* drop trailing whitespace */
4bc96ba6f1d67a90a75fa131bcd2cd508ea5a05aTimo Sirainen while (pos > 0 && QP_IS_TRAILING_SPACE(src[pos-1]))
19e8adccba16ff419f5675b1575358c2956dce83Timo Sirainen buffer_append(dest, src + next, src_pos - next);
4bc96ba6f1d67a90a75fa131bcd2cd508ea5a05aTimo Sirainen if ((ret = qp_is_end_of_line(src, &src_pos, src_size)) > 0) {
4bc96ba6f1d67a90a75fa131bcd2cd508ea5a05aTimo Sirainen /* =[whitespace][\r]\n */
4bc96ba6f1d67a90a75fa131bcd2cd508ea5a05aTimo Sirainen /* '=' was followed only by whitespace */
4bc96ba6f1d67a90a75fa131bcd2cd508ea5a05aTimo Sirainen /* '=' was followed by non-whitespace */
4bc96ba6f1d67a90a75fa131bcd2cd508ea5a05aTimo Sirainen /* non-hex data, show as-is */
4bc96ba6f1d67a90a75fa131bcd2cd508ea5a05aTimo Sirainen /* add everything but trailing spaces */
4bc96ba6f1d67a90a75fa131bcd2cd508ea5a05aTimo Sirainen while (src_pos > 0 && QP_IS_TRAILING_SPACE(src[src_pos-1]))
0f66f12eb4cdbf47670975044c88d8f388bf92dfTimo Sirainen buffer_append(dest, src + next, src_pos - next);
4bc96ba6f1d67a90a75fa131bcd2cd508ea5a05aTimo Sirainenint quoted_printable_decode(const unsigned char *src, size_t src_size,
4bc96ba6f1d67a90a75fa131bcd2cd508ea5a05aTimo Sirainen return quoted_printable_decode_full(src, src_size, src_pos_r, dest, FALSE);
4bc96ba6f1d67a90a75fa131bcd2cd508ea5a05aTimo Sirainenint quoted_printable_decode_final(const unsigned char *src, size_t src_size,
4bc96ba6f1d67a90a75fa131bcd2cd508ea5a05aTimo Sirainen return quoted_printable_decode_full(src, src_size, src_pos_r, dest, TRUE);
85144b5f0bc763de14c7d87291a90ef74ac241a2Timo Sirainenint quoted_printable_q_decode(const unsigned char *src, size_t src_size,
85144b5f0bc763de14c7d87291a90ef74ac241a2Timo Sirainen for (src_pos = 0; src_pos < src_size; src_pos++) {
85144b5f0bc763de14c7d87291a90ef74ac241a2Timo Sirainen if (src[src_pos] != '_' && src[src_pos] != '=')
85144b5f0bc763de14c7d87291a90ef74ac241a2Timo Sirainen buffer_append(dest, src + next, src_pos - next);
85144b5f0bc763de14c7d87291a90ef74ac241a2Timo Sirainen /* non-hex data, show as-is */