From 42b23133e80edce468240a74e09bf09f1834a46c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 13 Aug 2014 18:53:29 +0200 Subject: [PATCH] Fix UTF-8 handling of log files --- src/lib/Hydra/Controller/Build.pm | 5 +++-- src/lib/Hydra/Helper/Nix.pm | 3 ++- src/xsl/log2html.xsl | 4 +--- src/xsl/mark-errors.xsl | 4 +++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/lib/Hydra/Controller/Build.pm b/src/lib/Hydra/Controller/Build.pm index c390d143..bd38e7b9 100644 --- a/src/lib/Hydra/Controller/Build.pm +++ b/src/lib/Hydra/Controller/Build.pm @@ -12,6 +12,7 @@ use Data::Dump qw(dump); use Nix::Store; use Nix::Config; use List::MoreUtils qw(all); +use Encode; sub buildChain :Chained('/') :PathPart('build') :CaptureArgs(1) { @@ -141,9 +142,9 @@ sub showLog { # !!! quick hack my $pipeline = ($logPath =~ /.bz2$/ ? "bzip2 -d < $logPath" : "cat $logPath") . " | nix-log2xml | xsltproc " . $c->path_to("xsl/mark-errors.xsl") . " -" - . " | xsltproc " . $c->path_to("xsl/log2html.xsl") . " - | tail -n +2"; + . " | xsltproc " . $c->path_to("xsl/log2html.xsl") . " -"; $c->stash->{template} = 'log.tt'; - $c->stash->{logtext} = `ulimit -t 5 ; $pipeline`; + $c->stash->{logtext} = decode("utf-8", `ulimit -t 5 ; $pipeline`); } elsif ($mode eq "raw") { diff --git a/src/lib/Hydra/Helper/Nix.pm b/src/lib/Hydra/Helper/Nix.pm index 57db29c8..68d928a8 100644 --- a/src/lib/Hydra/Helper/Nix.pm +++ b/src/lib/Hydra/Helper/Nix.pm @@ -8,6 +8,7 @@ use Config::General; use Hydra::Helper::CatalystUtils; use Hydra::Model::DB; use Nix::Store; +use Encode; our @ISA = qw(Exporter); our @EXPORT = qw( @@ -310,7 +311,7 @@ sub logContents { else { $cmd = defined $tail ? "tail -$tail $logPath" : "cat $logPath"; } - return `$cmd`; + return decode("utf-8", `$cmd`); } diff --git a/src/xsl/log2html.xsl b/src/xsl/log2html.xsl index 04d85d7b..88c23637 100644 --- a/src/xsl/log2html.xsl +++ b/src/xsl/log2html.xsl @@ -2,9 +2,7 @@ - +

diff --git a/src/xsl/mark-errors.xsl b/src/xsl/mark-errors.xsl index 7551146d..18876bac 100644 --- a/src/xsl/mark-errors.xsl +++ b/src/xsl/mark-errors.xsl @@ -2,6 +2,8 @@ + + @@ -23,5 +25,5 @@ - +