diff --git a/fdroidserver/scanner.py b/fdroidserver/scanner.py index def865c0..a3af0260 100644 --- a/fdroidserver/scanner.py +++ b/fdroidserver/scanner.py @@ -16,7 +16,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import imghdr import itertools import json import logging @@ -35,6 +34,11 @@ from pathlib import Path from tempfile import TemporaryDirectory from typing import Union +try: + import magic +except ImportError: + import puremagic as magic + if sys.version_info >= (3, 11): import tomllib else: @@ -895,8 +899,12 @@ def scan_source(build_dir, build=metadata.Build(), json_per_build=None): ] def is_image_file(path): - if imghdr.what(path) is not None: - return True + try: + mimetype = magic.from_file(path, mime=True) + if mimetype and mimetype.startswith('image/'): + return True + except Exception as e: + logging.info(e) def safe_path(path_in_build_dir): for sp in safe_paths: diff --git a/setup.py b/setup.py index 25df9914..99fbe0fb 100755 --- a/setup.py +++ b/setup.py @@ -100,6 +100,7 @@ setup( 'paramiko', 'Pillow', 'apache-libcloud >= 0.14.1', + 'puremagic', 'python-vagrant', 'PyYAML', 'qrcode',