Defect #25563 » is_binary_data.patch
lib/redmine/scm/adapters/git_adapter.rb (revision ) | ||
---|---|---|
338 | 338 |
content = nil |
339 | 339 |
git_cmd(cmd_args) { |io| io.binmode; content = io.read } |
340 | 340 |
# git annotates binary files |
341 |
return nil if content.is_binary_data?
|
|
341 |
return nil if content.binary_data? |
|
342 | 342 |
identifier = '' |
343 | 343 |
# git shows commit author on the first occurrence only |
344 | 344 |
authors_by_commit = {} |
app/controllers/repositories_controller.rb (revision ) | ||
---|---|---|
200 | 200 |
return true if Redmine::MimeType.is_type?('text', path) |
201 | 201 |
# Ruby 1.8.6 has a bug of integer divisions. |
202 | 202 |
# http://apidock.com/ruby/v1_8_6_287/String/is_binary_data%3F |
203 |
return false if ent.is_binary_data?
|
|
203 |
return false if ent.binary_data? |
|
204 | 204 |
true |
205 | 205 |
end |
206 | 206 |
private :is_entry_text_data? |
lib/redmine/core_ext/string.rb (revision ) | ||
---|---|---|
5 | 5 |
include Redmine::CoreExtensions::String::Conversions |
6 | 6 |
include Redmine::CoreExtensions::String::Inflections |
7 | 7 | |
8 |
def is_binary_data?
|
|
8 |
def binary_data? |
|
9 | 9 |
( self.count( "^ -~", "^\r\n" ).fdiv(self.size) > 0.3 || self.index( "\x00" ) ) unless empty? |
10 | 10 |
end |
11 | 11 |
end |