mirror of
https://github.com/fluent/fluentd-ui.git
synced 2025-08-13 17:57:10 +02:00
Merge pull request #74 from kou/improve-binary-file-detection
Improve binary file detection
This commit is contained in:
commit
a712acfa3a
@ -36,8 +36,7 @@ class FileReverseReader
|
|||||||
|
|
||||||
def binary_file?
|
def binary_file?
|
||||||
sample = io.read(1024) || ""
|
sample = io.read(1024) || ""
|
||||||
sample2 = sample.force_encoding('ascii-8bit').encode('us-ascii', :undef => :replace, :invalid => :replace, :replace => "")
|
!sample.force_encoding('us-ascii').valid_encoding?
|
||||||
sample != sample2 # maybe binary file
|
|
||||||
ensure
|
ensure
|
||||||
io.rewind
|
io.rewind
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user