mirror of
https://github.com/inspec/inspec
synced 2024-11-23 21:23:29 +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
|
end
|
||||||
|
|
||||||
def read(file)
|
def read(file)
|
||||||
|
# TODO: this is inefficient
|
||||||
@contents[file] ||= read_from_zip(file)
|
@contents[file] ||= read_from_zip(file)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -141,6 +142,10 @@ module Inspec
|
||||||
next unless file == entry.name
|
next unless file == entry.name
|
||||||
|
|
||||||
res = io.read
|
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
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -174,7 +179,8 @@ module Inspec
|
||||||
res = entry.read || ""
|
res = entry.read || ""
|
||||||
try = res.dup
|
try = res.dup
|
||||||
try.force_encoding Encoding::UTF_8
|
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
|
res
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue