From b8dbb48fdce9ffc00d1f3f4267948ee2875d2970 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 21 Jan 2016 07:25:25 +0000 Subject: [PATCH] Force log messages to be bytestrings Sys::Syslog is not UTF-8-literate. --- IkiWiki.pm | 4 +++- t/syslog.t | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index fe5af6d15..97fe6b8ff 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -846,7 +846,9 @@ sub log_message ($$) { # keep a copy to avoid editing the original config repeatedly my $wikiname = $config{wikiname}; utf8::encode($wikiname); - Sys::Syslog::syslog($type, "[$wikiname] %s", join(" ", @_)); + my $message = join(" ", @_); + utf8::encode($message); + Sys::Syslog::syslog($type, "[$wikiname] %s", $message); }; if ($@) { print STDERR "failed to syslog: $@" unless $log_failed; diff --git a/t/syslog.t b/t/syslog.t index ffe8635b3..d5c1bc56b 100755 --- a/t/syslog.t +++ b/t/syslog.t @@ -12,7 +12,7 @@ $IkiWiki::config{syslog} = 1; $IkiWiki::config{wikiname} = 'ASCII'; is(debug('test'), '', 'plain ASCII syslog'); $IkiWiki::config{wikiname} = 'not ⒶSCII'; -is(debug('test'), '', 'UTF8 syslog'); +is(debug('𝗧ĕṡҭ'), '', 'UTF8 syslog'); my $orig = $IkiWiki::config{wikiname}; is(debug('test'), '', 'check for idempotency'); is($IkiWiki::config{wikiname}, $orig, 'unchanged config');