Skip to content

Conversation

@tisdall
Copy link

@tisdall tisdall commented Nov 17, 2025

Closes #205

Changes proposed in this pull request

If the header only contains plain 7-bit ASCII then there's no point in encoding with quoted-printable. Additionally, we need to fold content to try to keep within 78 characters per line (excluding CRLF). This PR keeps ASCII as ASCII, but folds at foldable whitespace. Also, reworks encoding-words to properly encoding spaces as "_" and to leave foldable space between blocks.

  • restructured encode_header_value:
    • to drop :quoted_printable and accept the header name (to help support folding on first line)
    • if only ASCII then do nothing
    • if encoding is needed:
      • put into blocks of up to 75 characters with space between to allow folding
      • make spaces into _ to prevent folding within an encoded word (and to follow the RFC)
  • do "folding" as a follow-up step as it quickly becomes confusing with email address fields that should be folded after commas and not just on any space
    • currently only does folding on "other" fields that aren't matched by more specific render_header_value/2 functions

@tisdall
Copy link
Author

tisdall commented Dec 4, 2025

Parts of this are now handled in #214 , but this PR also addressed other issues around line folding. Did you want me to rebase or did you want to handle those some other way?

@andrewtimberlake
Copy link
Collaborator

Sorry, I only saw this after I dealt with the encoding issue.
If you’d like to tackle normal folding you can rebase and handle that. You shouldn’t need to to handle the quoted printable folding because that’s handled by the encoding if non-ASCII (unless it needs additional work).
Folding is tricky because different headers have different rules. You’ve identified some structured headers but there are complicated rules for headers like DKIM and ARC sets etc

@tisdall
Copy link
Author

tisdall commented Dec 5, 2025

replaced with #219

@tisdall tisdall closed this Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unnecessary RFC2047 encoding when length >= 64

2 participants