sni / Thruk

Thruk is a multibackend monitoring webinterface for Naemon, Nagios, Icinga and Shinken using the Livestatus API.
http://www.thruk.org
Other
408 stars 148 forks source link

Accents not correctly handled in config tool #572

Closed jframeau closed 8 years ago

jframeau commented 8 years ago

Thruk 2.04

Accents in comments are not correctly handled when editing in raw mode.

jfr

jframeau commented 8 years ago

Just a try. Accents are now handled correctly on my install:

Force read_file to load utf-8 content

--- lib/Monitoring/Config/File.pm.old   2016-03-06 17:56:58.163219547 +0100
+++ lib/Monitoring/Config/File.pm   2016-03-06 17:57:04.967567694 +0100
@@ -557,7 +557,7 @@

     return $new_content if $self->{'deleted'};

-    return encode_utf8(read_file($self->{'path'})) unless $self->{'changed'};
+    return scalar read_file($self->{'path'}, binmode => ':encoding(UTF-8)') unless $self->{'changed'};

     my $linenr = 1;

file_content is utf-8 thx to get_new_file_content()

--- lib/Thruk/Controller/conf.pm.old    2016-03-06 17:55:16.945040496 +0100
+++ lib/Thruk/Controller/conf.pm    2016-03-06 17:55:26.597534400 +0100
@@ -2098,7 +2098,7 @@
         $c->stash->{'file_link'}     = $file->{'display'};
         $c->stash->{'file_name'}     = $file->{'display'};
         $c->stash->{'file_name'}     =~ s/^$files_root//gmx;
-        $c->stash->{'file_content'}  = decode_utf8($file->get_new_file_content());
+        $c->stash->{'file_content'}  = $file->get_new_file_content();
         $c->stash->{'template'}      = 'conf_objects_fileeditor.tt';
     }
     elsif(_is_extra_file($filename, $c->config->{'Thruk::Plugin::ConfigTool'}->{'edit_files'})) {
jframeau commented 8 years ago

Scenario: add some characters with accents in a comment. Apply, save changes to disk, reload then back to that comment and raw edit. I never edit the file directly.