From ac12722cb97a5c25f4c0b4c8f0ec3cf7b9e16a90 Mon Sep 17 00:00:00 2001
From: Guillaume Rousse <guillaume.rousse@renater.fr>
Date: Wed, 18 Apr 2018 16:17:59 +0200
Subject: [PATCH] enforce UTF8 for accounts file

---
 lib/AccountManager/Tools.pm | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/AccountManager/Tools.pm b/lib/AccountManager/Tools.pm
index 56209f4..c5a5960 100644
--- a/lib/AccountManager/Tools.pm
+++ b/lib/AccountManager/Tools.pm
@@ -95,14 +95,16 @@ sub update_ssp_authsources {
     my ($templates_dir, $output, $accounts) = @_;
 
     my $tt2 = Template->new({
-        INCLUDE_PATH => $templates_dir
+        ENCODING     => 'utf8',
+        INCLUDE_PATH => $templates_dir . '/accounts'
     });
-    my $template = 'accounts/accounts.php.tt2';
+    my $template = 'accounts.php.tt2';
     my $data = {
         accounts  => $accounts,
     };
 
-    $tt2->process($template, $data, $output) or die $tt2->error();
+    $tt2->process($template, $data, $output, { binmode => ':utf8' })
+        or die $tt2->error();
 }
 
 1;
-- 
GitLab