lib/inspec/file_provider.rb in inspec-4.18.24 vs lib/inspec/file_provider.rb in inspec-4.18.38
- old
+ new
@@ -121,10 +121,11 @@
end
end
end
def read(file)
+ # TODO: this is inefficient
@contents[file] ||= read_from_zip(file)
end
private
@@ -139,10 +140,14 @@
walk_zip(@path) do |io|
while (entry = io.get_next_entry)
next unless file == entry.name
res = io.read
+ try = res.dup
+ try.force_encoding Encoding::UTF_8
+ res = try.encode(try.encoding, universal_newline: true) if try.valid_encoding?
+
break
end
end
res
end
@@ -172,10 +177,11 @@
@contents[path] = begin # not ||= in a tarball, last one wins
res = entry.read || ""
try = res.dup
try.force_encoding Encoding::UTF_8
- res = try if try.valid_encoding?
+ res = try.encode(try.encoding, universal_newline: true) if
+ try.valid_encoding?
res
end
end
@files = @contents.keys