mirror of
				https://github.com/f-droid/fdroidserver.git
				synced 2025-11-04 06:30:27 +03:00 
			
		
		
		
	Merge branch 'drop_imghdr' into 'master'
scanner: replace deprecated imghdr with libmagic/puremagic See merge request fdroid/fdroidserver!1543
This commit is contained in:
		
						commit
						cd29dd84d2
					
				
					 2 changed files with 12 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -16,7 +16,6 @@
 | 
			
		|||
# You should have received a copy of the GNU Affero General Public License
 | 
			
		||||
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 | 
			
		||||
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:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										1
									
								
								setup.py
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								setup.py
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -100,6 +100,7 @@ setup(
 | 
			
		|||
        'paramiko',
 | 
			
		||||
        'Pillow',
 | 
			
		||||
        'apache-libcloud >= 0.14.1',
 | 
			
		||||
        'puremagic',
 | 
			
		||||
        'python-vagrant',
 | 
			
		||||
        'PyYAML',
 | 
			
		||||
        'qrcode',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue