Skip Menu |

This queue is for tickets about the MailTools CPAN distribution.

Report information
The Basics
Id: 26087
Status: resolved
Priority: 0/
Queue: MailTools

Owner: Nobody in particular
Requestors: robertojimenoca [...]

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)


Subject: Remove last newline from $entity->head->get('Subject')
Download (untitled) / with headers
text/plain 300b
When getting any header of a message with: my $header_subject = $entity->head->get('Subject'); $header_subject has the last newline in it. That is not very practical because you must always chomp it. It is even incongruent because if it is a multiline field the middle newlines are correctly removed.
Subject: MailHeader_unfold_lastnewline_remove_fix.diff
--- Mail/ +++ Mail/ @@ -383,7 +383,7 @@ $list = $me->{'mail_hdr_hash'}{$tag}; foreach $ln (@$list) { - $$ln =~ s/\r?\n\s+/ /sog + $$ln =~ s/\r?\n\s*/ /sog if defined $ln && defined $$ln; } } @@ -393,7 +393,7 @@ { foreach $ln (@$list) { - $$ln =~ s/\r?\n\s+/ /sog + $$ln =~ s/\r?\n\s*/ /sog if defined $ln && defined $$ln; } }
Download (untitled) / with headers
text/plain 619b
The removal of \n\s+ from the header field content is the removal of field folding, as desribed in the RFC. Folding can appear unexpectedly, introduced by mail transfer agents, and is therefore automatically removed. Actually, unfolding should only remove \n\s (without a \s*), but that's an historical mistake, which I cannot repair without breaking existing applications. For the same reason, I cannot remove the \n after the field content when it is returned: it will break existing code, and it is not worth that. If you want code which is RFC compliant and which does chomp for you, use MailBox, not MailTools.

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to