diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 8e39d42..0c8e68b 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -115,8 +115,13 @@ class RepositoriesController < ApplicationController @content = @repository.cat(@path, @rev) show_error_not_found and return unless @content if 'raw' == params[:format] || @content.is_binary_data? || (@entry.size && @entry.size > Setting.file_max_size_displayed.to_i.kilobyte) + # Try to guess the content-type + en = @entry.name + mime = Mime::Type.lookup_by_extension(en[en.rindex('.')+1, en.size].downcase) unless en.rindex('.').nil? + options = { :filename => @path.split('/').last } + options.merge!( :type => mime, :disposition => "inline" ) unless mime.nil? # Force the download - send_data @content, :filename => @path.split('/').last + send_data @content, options else # Prevent empty lines when displaying a file with Windows style eol @content.gsub!("\r\n", "\n")