Skip to content

Commit

Permalink
fix: avoid attempts to read negative size in file stream helper
Browse files Browse the repository at this point in the history
  • Loading branch information
macite committed Aug 1, 2024
1 parent 8139f41 commit 758a51d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/helpers/file_stream_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def stream_file(file_path)
end

# Return the requested content
content_length = end_point - begin_point + 1
content_length = [end_point - begin_point + 1, 0].max # Ensure we don't attempt to read a negative length
header['Access-Control-Expose-Headers'] = header.key?('Content-Disposition') ? 'Content-Disposition,Content-Range,Accept-Ranges' : 'Content-Range,Accept-Ranges'
header['Content-Range'] = "bytes #{begin_point}-#{end_point}/#{file_size}"
header['Content-Length'] = content_length.to_s
Expand Down

0 comments on commit 758a51d

Please sign in to comment.