From 7272dfa3c6d4c3c8877eea2a66fe84c7904cafa5 Mon Sep 17 00:00:00 2001 From: elijah Date: Mon, 24 Mar 2014 10:16:56 -0700 Subject: fixed problems when default encoding is not utf8 --- lib/leap_cli/config/macros.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/leap_cli/config/macros.rb') diff --git a/lib/leap_cli/config/macros.rb b/lib/leap_cli/config/macros.rb index 69b3a22..c6938fe 100644 --- a/lib/leap_cli/config/macros.rb +++ b/lib/leap_cli/config/macros.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 # # MACROS # these are methods available when eval'ing a value in the .json configuration @@ -60,9 +61,9 @@ module LeapCli; module Config filepath = Path.find_file(filename) if filepath if filepath =~ /\.erb$/ - ERB.new(File.read(filepath), nil, '%<>').result(binding) + ERB.new(File.read(filepath, :encoding => 'UTF-8'), nil, '%<>').result(binding) else - File.read(filepath) + File.read(filepath, :encoding => 'UTF-8') end else raise FileMissing.new(Path.named_path(filename), options) @@ -343,14 +344,14 @@ module LeapCli; module Config hash = {} keys = Dir.glob(Path.named_path([:user_ssh, '*'])) keys.sort.each do |keyfile| - ssh_type, ssh_key = File.read(keyfile).strip.split(" ") + ssh_type, ssh_key = File.read(keyfile, :encoding => 'UTF-8').strip.split(" ") name = File.basename(File.dirname(keyfile)) hash[name] = { "type" => ssh_type, "key" => ssh_key } end - ssh_type, ssh_key = File.read(Path.named_path(:monitor_pub_key)).strip.split(" ") + ssh_type, ssh_key = File.read(Path.named_path(:monitor_pub_key), :encoding => 'UTF-8').strip.split(" ") hash[Leap::Platform.monitor_username] = { "type" => ssh_type, "key" => ssh_key -- cgit v1.2.3