Skip to content

Commit

Permalink
Fix Email::MIME::Encode::maybe_mime_encode_header to work also withou…
Browse files Browse the repository at this point in the history
…t explicit "use Email::MIME::Header"

Email::MIME::Encode uses %Email::MIME::Header::header_to_class_map variable
but have not loaded Email::MIME::Header module. This patch fixes it.

Problem discovered by atoomic in report #52.
  • Loading branch information
pali authored and rjbs committed May 9, 2020
1 parent e0ce469 commit b41f2fb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/Email/MIME/Encode.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package Email::MIME::Encode;

use Carp ();
use Encode ();
use Email::MIME::Header;
use MIME::Base64();
use Module::Runtime ();
use Scalar::Util;
Expand Down
2 changes: 1 addition & 1 deletion lib/Email/MIME/Header.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ our @CARP_NOT;

our %header_to_class_map;

{
BEGIN {
my @address_list_headers = qw(from sender reply-to to cc bcc);
push @address_list_headers, map { "resent-$_" } @address_list_headers;
push @address_list_headers, map { "downgraded-$_" } @address_list_headers; # RFC 5504
Expand Down
19 changes: 19 additions & 0 deletions t/email-mime-encode.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use strict;
use warnings;
use utf8;
use Test::More;

BEGIN {
plan skip_all => 'Email::Address::XS is required for this test' unless eval { require Email::Address::XS };
plan 'no_plan';
}

BEGIN {
use_ok('Email::MIME::Encode');
}

is(
Email::MIME::Encode::maybe_mime_encode_header('To', '"Name ☺" <user@host>'),
'=?UTF-8?B?TmFtZSDimLo=?= <user@host>',
'Email::MIME::Encode::maybe_mime_encode_header works without "use Email::MIME::Header"'
);

0 comments on commit b41f2fb

Please sign in to comment.