From 8c4850abc7279f275625854992af6883d5cef7f6 Mon Sep 17 00:00:00 2001 From: Taiwudao Date: Sat, 21 Nov 2026 14:01:06 +0800 Subject: [PATCH] fix: recognize .heic and .heif as images Neither extension was in the extension map, so they fell through to the default text tag: >>> tags_from_filename('photo.heic') {'file', 'executable', 'text'} HEIC is the default camera format on recent iPhones, and describing it as text means hooks that process text files (pre-commit's end-of-file-fixer, trailing-whitespace, and anything else gated on the text tag) will happily rewrite binary photo data. Add both next to the other image formats. --- identify/extensions.py | 2 ++ tests/identify_test.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/identify/extensions.py b/identify/extensions.py index e0b5633..00e58a5 100644 --- a/identify/extensions.py +++ b/identify/extensions.py @@ -106,6 +106,8 @@ 'h': {'text', 'header', 'c', 'c++'}, 'hbs': {'text', 'handlebars'}, 'hcl': {'text', 'hcl'}, + 'heic': {'binary', 'image', 'heic'}, + 'heif': {'binary', 'image', 'heif'}, 'hlsl': {'text', 'hlsl'}, 'hlsli': {'text', 'hlsl'}, 'hh': {'text', 'header', 'c++'}, diff --git a/tests/identify_test.py b/tests/identify_test.py index a82f353..66b7e18 100644 --- a/tests/identify_test.py +++ b/tests/identify_test.py @@ -187,6 +187,8 @@ def test_tags_from_path_plist_text(tmpdir): # case of extension should be ignored ('f.JPG', {'binary', 'image', 'jpeg'}), + ('f.heic', {'binary', 'image', 'heic'}), + ('f.HEIF', {'binary', 'image', 'heif'}), # but case of name checks should still be honored ('dockerfile.py', {'text', 'python'}),