From 847c77de656f8a5d86440aeb2784c89b23ba3c65 Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Thu, 20 Jan 2022 23:47:18 +0200 Subject: [PATCH] FIX: Add another method to check binary file (#15648) This method looks for a NULL byte that is not usually contained in text files. Follow up to 376799b1a49306be500be3419a327af8b03819ec. --- lib/onebox/mixins/git_blob_onebox.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/onebox/mixins/git_blob_onebox.rb b/lib/onebox/mixins/git_blob_onebox.rb index ff72256f516..073f0fd27c0 100644 --- a/lib/onebox/mixins/git_blob_onebox.rb +++ b/lib/onebox/mixins/git_blob_onebox.rb @@ -169,7 +169,7 @@ module Onebox else contents = URI.parse(self.raw_template(m)).open(read_timeout: timeout).read - if contents.encoding == Encoding::BINARY + if contents.encoding == Encoding::BINARY || contents.bytes.include?(0) @raw = nil @binary = true return