houseabsolute / Courriel

High level email parsing and manipulation
https://metacpan.org/release/Courriel/
Other
6 stars 5 forks source link

Parsing should preserve the raw (folded) form of headers #6

Open autarch opened 6 years ago

autarch commented 6 years ago

Migrated from rt.cpan.org #84449 (status was 'new')

Requestors:

From drolsky@cpan.org (@autarch) on 2013-04-05 17:39:36:

For some uses, it is important to be able to recreate a given header exactly as it appeared in the original.

For example, when using DKIM to sign an email, if the sender uses the "simple" canonicalization method, then the DKIM signature is based on the raw byte-for-byte original header, including folding.

If you parse a DKIM signed email and then regenerate it with Courriel, this breaks the signing.

The fix is to preserve all the original whitespace in the header and store that as a new raw_string attribute for Courriel::Header objets. The as_string method should use this raw value when stringifying the header.

This raw_string attribute should store the the whole header (key & value) as it was seen in the original email, including all whitespace and line endings.