Merge pull request #4523 from reitermarkus/jar-detection

Fix JAR detection.
This commit is contained in:
Markus Reiter 2018-07-20 17:46:20 +02:00 committed by GitHub
commit 2dbffa2907
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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