Skip to content

Commit

Permalink
bpo-27240 Rewrite the email header folding algorithm. (GH-3488) (#4693)
Browse files Browse the repository at this point in the history
The original algorithm tried to delegate the folding to the tokens so
that those tokens whose folding rules differed could specify the
differences.  However, this resulted in a lot of duplicated code because
most of the rules were the same.

The new algorithm moves all folding logic into a set of functions
external to the token classes, but puts the information about which
tokens can be folded in which ways on the tokens...with the exception of
mime-parameters, which are a special case (which was not even
implemented in the old folder).

This algorithm can still probably be improved and hopefully simplified
somewhat.

Note that some of the test expectations are changed.  I believe the
changes are toward more desirable and consistent behavior: in general
when (re) folding a line the canonical version of the tokens is
generated, rather than preserving errors or extra whitespace.
(cherry picked from commit 85d5c18)
  • Loading branch information
miss-islington authored and bitdancer committed Dec 4, 2017
1 parent 30a6bc8 commit a87ba60
Show file tree
Hide file tree
Showing 6 changed files with 511 additions and 563 deletions.
Loading

0 comments on commit a87ba60

Please sign in to comment.