zip size limit

This commit is contained in:
Pete Matsyburka committed 2026-11-14 15:47:16 +02:00
1 parent e5b9ee9502
commit cd5cb9c082
1 file changed
+6 -4
+6 -4
View File
@@ -100,13 +100,15 @@ module Templates
Zip::File.open(file.tempfile).each do |entry| Zip::File.open(file.tempfile).each do |entry|
next if entry.directory? next if entry.directory?
total_size += entry.size tempfile = Tempfile.new(entry.name)
tempfile.binmode
total_size += entry.get_input_stream do |in_stream|
IO.copy_stream(in_stream, tempfile, MAX_ZIP_SIZE - total_size + 1)
end
raise InvalidFileType, 'zip_too_large' if total_size > MAX_ZIP_SIZE raise InvalidFileType, 'zip_too_large' if total_size > MAX_ZIP_SIZE
tempfile = Tempfile.new(entry.name)
tempfile.binmode
entry.get_input_stream { |in_stream| IO.copy_stream(in_stream, tempfile) }
tempfile.rewind tempfile.rewind
type = Marcel::MimeType.for(tempfile, name: entry.name) type = Marcel::MimeType.for(tempfile, name: entry.name)