From 979e6674cf8684ffbf7fbff7c8e2b70043e8c6af Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 20 Jul 2018 17:21:24 +0200 Subject: [PATCH] Fix JAR detection. --- Library/Homebrew/unpack_strategy.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/unpack_strategy.rb b/Library/Homebrew/unpack_strategy.rb index c01e94f01f..110b43f68b 100644 --- a/Library/Homebrew/unpack_strategy.rb +++ b/Library/Homebrew/unpack_strategy.rb @@ -125,8 +125,10 @@ class LuaRockUnpackStrategy < UncompressedUnpackStrategy return false unless ZipUnpackStrategy.can_extract?(path: path, magic_number: magic_number) # Check further if the ZIP is a LuaRocks package. - out, _, status = Open3.capture3("zipinfo", "-1", path) - status.success? && out.split("\n").any? { |line| line.match?(%r{\A[^/]+.rockspec\Z}) } + out, = Open3.capture3("zipinfo", "-1", path) + out.encode(Encoding::UTF_8, invalid: :replace) + .split("\n") + .any? { |line| line.match?(%r{\A[^/]+.rockspec\Z}) } end end @@ -135,8 +137,10 @@ class JarUnpackStrategy < UncompressedUnpackStrategy return false unless ZipUnpackStrategy.can_extract?(path: path, magic_number: magic_number) # Check further if the ZIP is a JAR/WAR. - out, _, status = Open3.capture3("zipinfo", "-1", path) - status.success? && out.split("\n").include?("META-INF/MANIFEST.MF") + out, = Open3.capture3("zipinfo", "-1", path) + out.encode(Encoding::UTF_8, invalid: :replace) + .split("\n") + .include?("META-INF/MANIFEST.MF") end end