[Git][reproducible-builds/diffoscope][master] Remove (broken) fuzzy matching of JSON files as file 5.35 (in buster, released...

Chris Lamb gitlab at salsa.debian.org
Mon May 11 14:42:41 UTC 2020



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
ba7b6e39 by Chris Lamb at 2020-05-11T15:40:14+01:00
Remove (broken) fuzzy matching of JSON files as file 5.35 (in buster, released 2018-10-18) supports recognising JSON data. (Closes: reproducible-builds/diffoscope#106)

It was broken anyway; the "or" in the logic when checking the file_header should have been an "and".

- - - - -


1 changed file:

- diffoscope/comparators/json.py


Changes:

=====================================
diffoscope/comparators/json.py
=====================================
@@ -2,7 +2,7 @@
 #
 # diffoscope: in-depth comparison of files, archives, and directories
 #
-# Copyright © 2016-2019 Chris Lamb <lamby at debian.org>
+# Copyright © 2016-2020 Chris Lamb <lamby at debian.org>
 #
 # diffoscope is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -34,14 +34,10 @@ except ImportError:  # noqa
 
 class JSONFile(File):
     DESCRIPTION = "JSON files"
+    FILE_TYPE_RE = re.compile(r'JSON data')  # Requires file 5.35+
 
     @classmethod
     def recognizes(cls, file):
-        # Try fuzzy matching for files not called .json
-        if not file.name.endswith('.json'):
-            if b'{' not in file.file_header or b'[' not in file.file_header:
-                return False
-
         with open(file.path, 'rb') as f:
             try:
                 file.parsed = json.loads(



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

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/ba7b6e392af7f8c89c2bd98993c98ee6bc962b84
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/20200511/6885f068/attachment.htm>


More information about the rb-commits mailing list