Merge pull request #763 from zuf/patch-1
Fix huge files regression (for undetected mime)
This commit is contained in:
commit
8d5dd8e8ce
1 changed files with 8 additions and 1 deletions
|
@ -24,7 +24,14 @@ module Middleman
|
|||
|
||||
ext = ".#{ext}" unless ext.to_s[0] == ?.
|
||||
mime = ::Rack::Mime.mime_type(ext, nil)
|
||||
return false unless mime
|
||||
unless mime
|
||||
binary_bytes = [0, 1, 2, 3, 4, 5, 6, 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, 29, 30, 31]
|
||||
s = File.read(filename, 4096) || ''
|
||||
s.each_byte do |c|
|
||||
return true if binary_bytes.include?(c)
|
||||
end
|
||||
return false
|
||||
end
|
||||
return false if mime.start_with?('text/')
|
||||
return false if mime.include?('xml')
|
||||
return false if mime.include?('json')
|
||||
|
|
Loading…
Reference in a new issue