[Email-SIG] header folding

R. David Murray rdmurray at bitdance.com
Wed Jul 27 22:56:19 CEST 2011


On Tue, 26 Jul 2011 11:07:03 -0400, Barry Warsaw <barry at python.org> (by way of Barry Warsaw <barry at python.org>) wrote:
> On Jul 26, 2011, at 08:38 AM, R. David Murray wrote:
> >What's the word for what is done when a text message is made to have
> >a line length of less than 78 by using quoted printable (or base64)
> >encoding?  Is that also folding?  If there's no existing term in common
> >use, folding would make sense to me.  So I have no objection to using
> >'fold' consistently in the api and code for these operations.
> 
> Haven't we used 'splitting' as a term for this, at least internally, in
> previous versions?  That's at least what I think of, and I do think we could
> have two knows to control the different functionality:

'split' and 'wrap' seem to be used somewhat interchangeably in the
current code and docs.  I'm now consistently using 'fold' in the new
code.

> - To 'split' a line means to take a line longer than a specified maximum, and
>   make it fit into the maximum line length, splitting at whitespace or other
>   semantic separators.

My current code doesn't do this anywhere.  The old code does.

> - To 'fill' a header means to take the logical contents of the header and
>   recombine and resplit it so that each line is as close to the maximum line
>   length as possible.  My analogy here is Emacs's M-q (fill-paragraph).

Neither my current code nor the old code does exactly this anywhere.

> What then is "folding" or "wrapping"?  Maybe no different than the above.

Folding is an RFC term-of-art that implies the specific RFC rules for
making sure a semantic unit (header, body) has lines that are shorter
than the RFC defined maximum length.

Wrapping is much more like your 'filling', but probably a less precise
term, as filling does imply maximizing line lengths, while wrapping
to my ears does not have that connotation as a requirement.

'refolding', as I've implemented it, consists of taking an existing folded
header, unfolding it, and then folding it according to the RFC rules and
recommendations.  This may or may not put the maximum possible number
of characters on a line, depending on whether the header is structured
or unstructured and the content of said header.  And it may or may not
exactly reproduce the original header, depending on how closely the
original folder and I agree on our interpretation of the RFC rules :)
(Which is why headers are only refolded by explicit request.)

So, I agree with Stephen, I think 'folding' is the correct term to
use here.

> >Can anyone see a use case for controlling folding of headers separately
> >from folding of message bodies?  I haven't thought of one, which is why
> >I'm thinking one policy knob controls both.
> 
> You might have a message body that contains code, in which case you might want
> to fill the headers (using the terminology above), but not fill the body.

This is similar to the case we've already discussed, about excluding
a text body from being QP encoded.  I think we don't currently do
any paragraph reflow, but it might be an interesting facility to add :)

--
R. David Murray           http://www.bitdance.com


More information about the Email-SIG mailing list