Skip to content

Instantly share code, notes, and snippets.

@zsprackett
Created June 21, 2016 23:20
Show Gist options
  • Save zsprackett/7d7051eb68468bc9ee4c63c4f042c65e to your computer and use it in GitHub Desktop.
Save zsprackett/7d7051eb68468bc9ee4c63c4f042c65e to your computer and use it in GitHub Desktop.
diff --git a/lib/hbc/container/zip.rb b/lib/hbc/container/zip.rb
index 5425d7f..2d59064 100644
--- a/lib/hbc/container/zip.rb
+++ b/lib/hbc/container/zip.rb
@@ -1,6 +1,6 @@
class Hbc::Container::Zip < Hbc::Container::Base
def self.me?(criteria)
- criteria.file.include? 'compressed-encoding=application/zip;'
+ criteria.file.include? 'compressed-encoding=application/zip;' or 'application/zip; charset=binary'
end
def extract
@reitermarkus
Copy link

This is actually not doing what you think it does.

criteria.file.include? 'compressed-encoding=application/zip;' or 'application/zip; charset=binary'

is effectively this:

criteria.file.include?('compressed-encoding=application/zip;') or 'application/zip; charset=binary'

So, if criteria.file.include?('compressed-encoding=application/zip;') evaluates to false, the return value will be the string 'application/zip; charset=binary'. This leads to a non-nil return value no matter what.

@zachwalton
Copy link

diff --git a/lib/hbc/container/zip.rb b/lib/hbc/container/zip.rb
index 8118f9c..0a54cda 100644
--- a/lib/hbc/container/zip.rb
+++ b/lib/hbc/container/zip.rb
@@ -1,6 +1,6 @@
 class Hbc::Container::Zip < Hbc::Container::Base
   def self.me?(criteria)
-    criteria.file.include? "compressed-encoding=application/zip;"
+    criteria.file.include? "compressed-encoding=application/zip;" or criteria.file.include? "application/zip; charset=binary"
   end

   def extract

@salimane
Copy link

salimane commented Jul 8, 2016

@zachwalton, how do you apply this fix on a running homebrew ?

@vknabel
Copy link

vknabel commented Jul 13, 2016

@salimane You need to apply the changes to /usr/local/Library/Taps/caskroom/homebrew-cask/lib/hbc/container/zip.rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment