From 9826234d687b4f61d5ecf573ed878bf73f778f53 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jul 15 2015 09:25:30 +0000 Subject: Look for the null byte in binary file --- diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index 4ba145a..195c37f 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -2371,6 +2371,4 @@ def clean_input(text): def is_binary(text): """ Returns wether we think this text correspond to a binary file or not """ - textchars = bytearray([7,8,9,10,12,13,27]) + bytearray(range(0x20, 0x100)) - is_binary_string = lambda bytes: bool(bytes.translate(None, textchars)) - return is_binary_string(text) + return '\0' in text