Skip to content
Commits on Source (6)
......@@ -89,10 +89,6 @@ Package: diffoscope
Architecture: all
Suggests:
libjs-jquery,
Breaks:
debbindiff (<< 29),
Replaces:
debbindiff (<< 29),
Depends:
python3-distutils | libpython3.5-stdlib | libpython3.6-stdlib (<< 3.6.5~rc1-2),
python3-pkg-resources,
......
......@@ -83,7 +83,7 @@ class FsImageFile(File):
@classmethod
def recognizes(cls, file):
# Avoid DOS / MBR file type as it generate a lot of false possitives,
# Avoid DOS / MBR file type as it generate a lot of false positives,
# manually check "System identifier string" instead
with open(file.path, 'rb') as f:
f.seek(54)
......
......@@ -35,14 +35,12 @@ class JSONFile(File):
@classmethod
def recognizes(cls, file):
with open(file.path, 'rb') as f:
# Try fuzzy matching for JSON files
if not file.name.endswith('.json'):
buf = f.read(10)
if not any(x in buf for x in b'{['):
return False
f.seek(0)
# 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(
f.read().decode('utf-8', errors='ignore'),
......
......@@ -65,11 +65,12 @@ class PpuFile(File):
def recognizes(cls, file):
if not super().recognizes(file):
return False
with open(file.path, 'rb') as f:
magic = f.read(3)
if magic != b"PPU":
return False
ppu_version = f.read(3).decode('ascii', errors='ignore')
if file.file_header.startswith(b'PPU'):
return False
ppu_version = f.file_header[3:6].decode('ascii', errors='ignore')
if not hasattr(PpuFile, 'ppu_version'):
try:
with profile('command', 'ppudump'):
......
......@@ -42,9 +42,8 @@ class WasmFile(File):
def recognizes(cls, file):
if not super().recognizes(file):
return False
with open(file.path, 'rb') as f:
magic = f.read(4)
return magic == WASM_MAGIC
return file.file_header.startswith(WASM_MAGIC)
def compare_details(self, other, source=None):
return [Difference.from_command(Wasm2Wat, self.path, other.path)]
......@@ -105,10 +105,10 @@ def test_mozzip_metadata(mozzip_differences, mozzip1, mozzip2):
@skip_unless_tools_exist('zipinfo')
def test_mozzip_compressed_files(mozzip_differences):
assert mozzip_differences[1].source1 == 'dir/text'
assert mozzip_differences[1].source2 == 'dir/text'
assert mozzip_differences[-1].source1 == 'dir/text'
assert mozzip_differences[-1].source2 == 'dir/text'
expected_diff = get_data('text_ascii_expected_diff')
assert mozzip_differences[1].unified_diff == expected_diff
assert mozzip_differences[-1].unified_diff == expected_diff
@skip_unless_tools_exist('zipinfo')
......