]> gitweb.fluxo.info Git - leap/leap_cli.git/commitdiff
attempt to fix file loading problem when the OS has a weird default encoding.
authorelijah <elijah@riseup.net>
Wed, 8 May 2013 07:15:18 +0000 (00:15 -0700)
committerelijah <elijah@riseup.net>
Wed, 8 May 2013 07:15:18 +0000 (00:15 -0700)
lib/leap_cli/config/manager.rb

index f5282c56036f6455d3861513512518bbf7abb4cc..0d145418d8e22a867bd21986e7e9a873082be310 100644 (file)
@@ -185,11 +185,13 @@ module LeapCli
         log :loading, filename, 2
 
         #
-        # read file, strip out comments
-        # (File.read(filename) would be faster, but we like ability to have comments)
+        # Read a JSON file, strip out comments.
+        #
+        # UTF8 is the default encoding for JSON, but others are allowed:
+        # https://www.ietf.org/rfc/rfc4627.txt
         #
         buffer = StringIO.new
-        File.open(filename) do |f|
+        File.open(filename, "rb") do |f|
           while (line = f.gets)
             next if line =~ /^\s*\/\//
             buffer << line