]> git.donarmstrong.com Git - debbugs.git/commitdiff
warn if recips is in the wrong encoding
authorDon Armstrong <don@donarmstrong.com>
Thu, 14 Mar 2013 21:16:25 +0000 (14:16 -0700)
committerDon Armstrong <don@donarmstrong.com>
Thu, 14 Mar 2013 21:16:25 +0000 (14:16 -0700)
Debbugs/Log.pm

index 8b99b7de7a097207ffbe6abff3848edeae63fe52..551fd392a36fafea8b452377e30f19dbdc20d266 100644 (file)
@@ -405,6 +405,15 @@ sub write_log_records
            if (defined $recips) {
                croak "recips not undef or array"
                    unless ref($recips) eq 'ARRAY';
+                my $wrong_encoding = 0;
+                my @recips =
+                    map { if (is_utf8($_)) {
+                        $wrong_encoding=1;
+                        encode_utf8($_);
+                    } else {
+                        $_;
+                    }} @$recips;
+                carp('Recipients was in the wrong encoding (perl internal instead of utf8 octets') if $wrong_encoding;
                print {$logfh} join("\04", @$recips) . "\n" or
                    die "Unable to write to logfile: $!";
            } else {