Skip to content

Commit

Permalink
Fix unicode bug in subject
Browse files Browse the repository at this point in the history
Fixes a bug where unicode chars in the subject aren't properly encoded:
Wide character in syswrite at /usr/local/lib/perl5/5.30.0/Net/Cmd.pm line 210.
  • Loading branch information
waterkip committed Oct 11, 2019
1 parent 2ba12b4 commit e01a9e4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/Act/Email.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use strict;
package Act::Email;

use Encode ();
use Encode qw(encode);
#use List::Pairwise qw(mapp);

use Act::Config;
Expand Down Expand Up @@ -67,9 +67,10 @@ sub send
);
$args{body} = $dump . $args{body};

push @headers, ( To => Email::Address->new('Act tester', $Config->email_test)->format(),
Subject => "[TEST] $args{subject}",
);
push @headers,
(To => Email::Address->new('Act tester', $Config->email_test)
->format());
$args{subject} = "[TEST] $args{subject}";
}
else {
for my $header ( grep { exists $args{$_} } qw( to cc bcc ) )
Expand All @@ -81,8 +82,8 @@ sub send
push @headers,
( ucfirst $header => join ', ', map { $_->format() } @recips );
}
push @headers, ( Subject => $args{subject} );
}
push @headers, ( Subject => encode('MIME-Header', $args{subject} ));

my $charset;
if ( $args{body} =~ /^\p{InBasicLatin}+$/ ) {
Expand Down

0 comments on commit e01a9e4

Please sign in to comment.