mirror of
https://github.com/inspec/inspec
synced 2024-11-10 07:04:15 +00:00
Changed FileProvider to try to encode UTF-8 and convert newlines.
For Windows compatibility.
This commit is contained in:
parent
4242937bea
commit
d829fa2d61
1 changed files with 7 additions and 1 deletions
|
@ -123,6 +123,7 @@ module Inspec
|
|||
end
|
||||
|
||||
def read(file)
|
||||
# TODO: this is inefficient
|
||||
@contents[file] ||= read_from_zip(file)
|
||||
end
|
||||
|
||||
|
@ -141,6 +142,10 @@ module Inspec
|
|||
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
|
||||
|
@ -174,7 +179,8 @@ module Inspec
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue