Patch #6416 ยป repositories_controller.patch
| app/controllers/repositories_controller.rb 2010-09-15 06:48:44.000000000 +0900 | ||
|---|---|---|
|
require 'SVG/Graph/Bar'
|
||
|
require 'SVG/Graph/BarHorizontal'
|
||
|
require 'digest/sha1'
|
||
|
require 'iconv'
|
||
|
class ChangesetNotFound < Exception; end
|
||
|
class InvalidRevisionParam < Exception; end
|
||
| ... | ... | |
|
@content = @repository.cat(@path, @rev)
|
||
|
(show_error_not_found; return) unless @content
|
||
|
if 'raw' == params[:format] || @content.is_binary_data? || (@entry.size && @entry.size > Setting.file_max_size_displayed.to_i.kilobyte)
|
||
|
if 'raw' == params[:format] || is_binary?(@content) || (@entry.size && @entry.size > Setting.file_max_size_displayed.to_i.kilobyte)
|
||
|
# Force the download
|
||
|
send_data @content, :filename => @path.split('/').last
|
||
|
else
|
||
| ... | ... | |
|
graph.burn
|
||
|
end
|
||
|
def is_binary?(data)
|
||
|
return true if data =~ /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/n
|
||
|
begin
|
||
|
Iconv.iconv('utf-8', 'utf-8', data)
|
||
|
return false
|
||
|
rescue
|
||
|
return true
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
class Date
|
||