Skip Menu |

This queue is for tickets about the MIME-tools CPAN distribution.

Report information
The Basics
Id: 114182
Status: new
Priority: 0/
Queue: MIME-tools

People
Owner: Nobody in particular
Requestors: NERDVANA [...] cpan.org
Cc:
AdminCc:

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



Subject: Add helper method "get_decoded" for headers.
Hi, love the module for its ability to parse messages without pulling everything into RAM. Great design. However, I have to complain about the MIME::Head decode/unfold situation. It appears the old practice was to ->decode and then ->unfold. Then you deprecated ->decode. But, now it requires multiple lines of code to extract each attribute value, which is highly annoying. Could you please add a "get_decoded" method which both decodes the value into UTF-8 and un-folds it, and does this right as the value is being read without affecting the internal representation? After reading your source code a bit, I came up with this utility method (but maybe you know a more correct way to write it according to RFCs or whatnot) sub MIME::Head::get_decoded { my $value= shift->get(@_); $value= decode_mimewords($value); # Copied from Mail::Header, since there's no standalone utility function that I can find for this! $value =~ s/\r?\n\s+/ /sog; $value; }
Maybe also trim the final newline from the header. If 'decoded' doesn't describe this well enough then maybe name it 'get_logical' or 'get_value'? sub MIME::Head::get_decoded { my $value= shift->get(@_); $value= decode_mimewords($value); $value =~ s/\r?\n\s+/ /sog; $value =~ s/\r?\n$//s; $value; }