]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
Don't fail to syslog if the wiki name contains %s
authorSimon McVittie <smcv@debian.org>
Thu, 21 Jan 2016 07:32:55 +0000 (07:32 +0000)
committerSimon McVittie <smcv@debian.org>
Thu, 21 Jan 2016 07:33:41 +0000 (07:33 +0000)
This is a corner case spotted while fixing UTF-8 syslogging.

IkiWiki.pm
t/syslog.t

index 97fe6b8ffa035032812a8340e7b1953e06277282..0f27ac419d625aea235184f54fd889a0523ffcfa 100644 (file)
@@ -843,12 +843,9 @@ sub log_message ($$) {
                        $log_open=1;
                }
                eval {
-                       # keep a copy to avoid editing the original config repeatedly
-                       my $wikiname = $config{wikiname};
-                       utf8::encode($wikiname);
-                       my $message = join(" ", @_);
+                       my $message = "[$config{wikiname}] ".join(" ", @_);
                        utf8::encode($message);
-                       Sys::Syslog::syslog($type, "[$wikiname] %s", $message);
+                       Sys::Syslog::syslog($type, "%s", $message);
                };
                 if ($@) {
                     print STDERR "failed to syslog: $@" unless $log_failed;
index d5c1bc56bdcac0da6d9874ca672102177e0128c6..b9f366f1960a618c534d029f057165af830c2df9 100755 (executable)
@@ -11,7 +11,7 @@ $IkiWiki::config{syslog} = 1;
 
 $IkiWiki::config{wikiname} = 'ASCII';
 is(debug('test'), '', 'plain ASCII syslog');
-$IkiWiki::config{wikiname} = 'not ⒶSCII';
+$IkiWiki::config{wikiname} = 'not ⒶSCII and has %s in it';
 is(debug('𝗧ĕṡҭ'), '', 'UTF8 syslog');
 my $orig = $IkiWiki::config{wikiname};
 is(debug('test'), '', 'check for idempotency');