X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/0b06986039976e3c786a3fbaeec6ced475734002..431ad4c8e15167c441b5bac9801072aa6ad18bfa:/sbr/encode_rfc2047.c diff --git a/sbr/encode_rfc2047.c b/sbr/encode_rfc2047.c index 54a1e088..ac2b6dc3 100644 --- a/sbr/encode_rfc2047.c +++ b/sbr/encode_rfc2047.c @@ -125,14 +125,14 @@ encode_rfc2047(const char *name, char **value, int encoding, * On the encoding we choose, and the specifics of encoding: * * - If a specified encoding is passed in, we use that. - * - If more than 50% of the characters are high-bit, we use base64 - * and encode the whole field as one atom (possibly split). - * - Otherwise, we use quoted-printable. + * - Otherwise, pick which encoding is shorter. + * + * We don't quite handle continuation right here, but it should be + * pretty close. */ if (encoding == CE_UNKNOWN) - encoding = (eightbitcount * 10 / (asciicount + eightbitcount) > 5) ? - CE_BASE64 : CE_QUOTED; + encoding = pref_encoding(asciicount, qpspecialcount, eightbitcount); unfold_header(value, asciicount + eightbitcount); @@ -517,8 +517,8 @@ unfold_header(char **value, int len) * This has the side effect of stripping off the final newline * for the header; we put it back in the encoding routine. */ - while (is_fws(*q++)) - ; + while (is_fws(*q)) + q++; if (*q == '\0') break; @@ -721,8 +721,8 @@ do_reformat: */ if (groupflag && ! mn->m_ingrp) { - output = add("; ", output); - column += 2; + output = add(";", output); + column += 1; } groupflag = mn->m_ingrp;