[Git][reproducible-builds/diffoscope][master] comparators/json: Try fuzzy matching for non-text files too. (Closes: #909122)

Chris Lamb gitlab at salsa.debian.org
Wed Sep 19 11:30:14 CEST 2018


Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
4ba7e6c8 by Marek Marczykowski-Górecki at 2018-09-19T09:29:31Z
comparators/json: Try fuzzy matching for non-text files too. (Closes: #909122)

Non-text files have even less change being json files, so this fuzzy early
elimination is even more useful for them.  In particular, it avoids loading
large files (like ISO images) just to discover it isn't a JSON format.

Signed-off-by: Chris Lamb <lamby at debian.org>

- - - - -


1 changed file:

- diffoscope/comparators/json.py


Changes:

=====================================
diffoscope/comparators/json.py
=====================================
@@ -37,11 +37,7 @@ class JSONFile(File):
     def recognizes(cls, file):
         with open(file.path, 'rb') as f:
             # Try fuzzy matching for JSON files
-            is_text = any(
-                file.magic_file_type.startswith(x)
-                for x in ('ASCII text', 'UTF-8 Unicode text')
-            )
-            if is_text and not file.name.endswith('.json'):
+            if not file.name.endswith('.json'):
                 buf = f.read(10)
                 if not any(x in buf for x in b'{['):
                     return False



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/commit/4ba7e6c8657e6d82f8c3d2a97a3677245f1dfe7d

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/commit/4ba7e6c8657e6d82f8c3d2a97a3677245f1dfe7d
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20180919/eab8b3b8/attachment.html>


More information about the rb-commits mailing list