Subject: | Mail::Header unfolding in get() is incomplete |
Date: | Sat, 13 Apr 2019 18:31:29 -0400 |
To: | bug-MIME-tools [...] rt.cpan.org |
From: | tlhackque <tlhackque [...] yahoo.com> |
Mail::Tools 2.20
I noticed that in Mail::Header, the unfolding code is incorrect.
In unfold(), the unfolding correctly handles a header that extends over
more than two lines. (e.g. two or more continuations.) E.g.
| ||foreach| |my| |$ln| |(||@$list||)|
| ||{ ||$$ln| |=~ s/\r?\n\s+/ /sog|
| ||if| |defined| |$ln| |&& ||defined| |$$ln||;|
| ||}|
In get(), the unfolding is done with:
| ||$val| |=~ s/^\s+//;|
Note the missing 's' and 'g' qualifiers (and 'o', but that's not
functional).
Thus, only the first continuation will be removed.
The error occurs in two places in get() (the single tag and all tags cases).
The work-around is to do $head->unfold('foo')->get('foo');