fix MIME::Entity usage for perl 5.18+, RT#77890
authorIvan Kohler <ivan@freeside.biz>
Tue, 17 Oct 2017 21:43:52 +0000 (14:43 -0700)
committerIvan Kohler <ivan@freeside.biz>
Tue, 17 Oct 2017 21:43:52 +0000 (14:43 -0700)
FS/FS/Misc.pm
FS/FS/Template_Mixin.pm
FS/FS/TicketSystem/RT_Internal.pm

index a2d1b3e..4d9d57b 100644 (file)
@@ -157,7 +157,10 @@ sub send_email {
       unshift @mimeparts, { 
         'Type'        => ( $options{'content-type'} || 'text/plain' ),
         'Charset'     => 'UTF-8',
       unshift @mimeparts, { 
         'Type'        => ( $options{'content-type'} || 'text/plain' ),
         'Charset'     => 'UTF-8',
-        'Data'        => $options{'body'},
+        'Data'        => ( $options{'content-type'} =~ /^text\//
+                             ? Encode::encode_utf8( $options{'body'} )
+                             : $options{'body'}
+                         ),
         'Encoding'    => ( $options{'content-type'} ? '-SUGGEST' : '7bit' ),
         'Disposition' => 'inline',
       };
         'Encoding'    => ( $options{'content-type'} ? '-SUGGEST' : '7bit' ),
         'Disposition' => 'inline',
       };
@@ -166,7 +169,10 @@ sub send_email {
     
       @mimeargs = (
         'Type'     => ( $options{'content-type'} || 'text/plain' ),
     
       @mimeargs = (
         'Type'     => ( $options{'content-type'} || 'text/plain' ),
-        'Data'     => $options{'body'},
+        'Data'     => ( $options{'content-type'} =~ /^text\//
+                          ? Encode::encode_utf8( $options{'body'} )
+                          : $options{'body'}
+                      ),
         'Encoding' => ( $options{'content-type'} ? '-SUGGEST' : '7bit' ),
         'Charset'  => 'UTF-8',
       );
         'Encoding' => ( $options{'content-type'} ? '-SUGGEST' : '7bit' ),
         'Charset'  => 'UTF-8',
       );
@@ -377,7 +383,7 @@ sub generate_email {
     'Encoding'    => 'quoted-printable',
     'Charset'     => 'UTF-8',
     #'Encoding'    => '7bit',
     'Encoding'    => 'quoted-printable',
     'Charset'     => 'UTF-8',
     #'Encoding'    => '7bit',
-    'Data'        => $data,
+    'Data'        => Encode::encode_utf8($data),
     'Disposition' => 'inline',
   );
 
     'Disposition' => 'inline',
   );
 
@@ -398,7 +404,7 @@ sub generate_email {
                        '    </title>',
                        '  </head>',
                        '  <body bgcolor="#ffffff">',
                        '    </title>',
                        '  </head>',
                        '  <body bgcolor="#ffffff">',
-                       @html_data,
+                       ( map Encode::encode_utf8($_), @html_data ),
                        '  </body>',
                        '</html>',
                      ],
                        '  </body>',
                        '</html>',
                      ],
index 2dcf7d0..7dc8139 100644 (file)
@@ -2115,6 +2115,7 @@ Returns an argument list to be passed to L<FS::Misc::send_email>.
 =cut
 
 use MIME::Entity;
 =cut
 
 use MIME::Entity;
+use Encode;
 
 sub generate_email {
 
 
 sub generate_email {
 
@@ -2191,7 +2192,7 @@ sub generate_email {
         if $DEBUG;
 
       # 'print_text' argument is no longer used
         if $DEBUG;
 
       # 'print_text' argument is no longer used
-      @text = $self->print_text(\%args);
+      @text = map Encode::encode_utf8($_), $self->print_text(\%args);
 
     } else {
 
 
     } else {
 
@@ -2286,7 +2287,7 @@ sub generate_email {
                          '    </title>',
                          '  </head>',
                          '  <body bgcolor="#e8e8e8">',
                          '    </title>',
                          '  </head>',
                          '  <body bgcolor="#e8e8e8">',
-                         $html,
+                         Encode::encode_utf8($html),
                          '  </body>',
                          '</html>',
                        ],
                          '  </body>',
                          '</html>',
                        ],
index 99e7044..3da68d9 100644 (file)
@@ -5,6 +5,7 @@ use vars qw( @ISA $DEBUG $me );
 use Data::Dumper;
 use Date::Format qw( time2str );
 use MIME::Entity;
 use Data::Dumper;
 use Date::Format qw( time2str );
 use MIME::Entity;
+use Encode;
 use FS::UID qw(dbh);
 use FS::CGI qw(popurl);
 use FS::TicketSystem::RT_Libs;
 use FS::UID qw(dbh);
 use FS::CGI qw(popurl);
 use FS::TicketSystem::RT_Libs;
@@ -374,7 +375,7 @@ sub create_ticket {
              : ( $param{'cc'} ? [ $param{'cc'} ] : [] );
 
   my $mimeobj = MIME::Entity->build(
              : ( $param{'cc'} ? [ $param{'cc'} ] : [] );
 
   my $mimeobj = MIME::Entity->build(
-    'Data' => $param{'message'},
+    'Data' => Encode::encode_utf8( $param{'message'} ),
     'Type' => ( $param{'mime_type'} || 'text/plain' ),
   );
 
     'Type' => ( $param{'mime_type'} || 'text/plain' ),
   );