[Top] [All Lists]

Re: [ietf-smtp] quoted-unprintable ?

2021-03-25 13:59:11
On Thu, Mar 25, 2021 at 01:11:12PM -0400, John R Levine wrote:

That's quite clever, although it only avoids a single value and it's not 
immediately obvious how to extend it to multiple values.  Applying it
iteratively for different values wouldn't work.

There's an easy generalisation to 3 forbidden code points: use 6 bits
for the chunk length, with 2 high bits for which of the 3 forbidden
sequences terminates the chunk.

    01 - NUL |
    10 - NL  | 6-bit byte count
    11 - CR  |

A non-zero value (n) of the 6-bit count indicates a run of (n-1) literal
bytes none of which are the reserved bytes NUL, LF or CR, followed by the
indicated reserved byte.  When (n == 0) the 2 high bits signal, respectively,
63, 126 or 189 literal bytes without a following reserved byte.

This encoding adds at most one byte for every 63, generating 8-bit
data that is free of NUL, CR and LF characters, which can then
be used for framing.

One can then generate output lines that are 78 bytes long, adding
another factor of 1/40, for a combined cost in the range [2.56%, 4.2%).


ietf-smtp mailing list