Bug 21875: Handling subject line in Letters.pm
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Fri, 23 Nov 2018 10:36:49 +0000 (11:36 +0100)
committerNick Clemens <nick@bywatersolutions.com>
Wed, 27 Feb 2019 14:14:21 +0000 (09:14 -0500)
The variable name $utf8 is very misleading: it contains MIME-Header encoding.
$message->{subject} comes from the database and is in perl internal format;
it should NOT be decoded as a MIME-Header.
After encoding to MIME-Header, previously another (useless) encoding to
UTF-8 was done. Since the string is plain ASCII, this is useless and
theoretically wrong. We should stay in MIME-Header.

Test plan:
See Bugzilla comment5.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

C4/Letters.pm

index bf94c0e..cbe6559 100644 (file)
@@ -1284,9 +1284,10 @@ sub _send_message_by_email {
         }
     }
 
-    my $utf8   = decode('MIME-Header', $message->{'subject'} );
-    $message->{subject}= encode('MIME-Header', $utf8);
-    my $subject = encode('UTF-8', $message->{'subject'});
+    # Encode subject line separately
+    $message->{subject} = encode('MIME-Header', $message->{'subject'} );
+    my $subject = $message->{'subject'};
+
     my $content = encode('UTF-8', $message->{'content'});
     my $content_type = $message->{'content_type'} || 'text/plain; charset="UTF-8"';
     my $is_html = $content_type =~ m/html/io;