feat(convert): averti en cas d extension de fichier suspecte
This commit is contained in:
parent
75eae59ee4
commit
ae576d1a38
@ -86,8 +86,16 @@ def download(src, filename, force_download):
|
||||
return path
|
||||
|
||||
|
||||
def get_extension(path):
|
||||
ext = path.split('.')[-1]
|
||||
if len(ext) < 2 or len(ext) > 4:
|
||||
logger.warn('Extension curieuse: {}'.format(path))
|
||||
ext = None
|
||||
return ext or 'unknown'
|
||||
|
||||
|
||||
def fetch_document(src, filename, force_download):
|
||||
extension = filename.split('.')[-1] or 'unknown'
|
||||
extension = get_extension(filename)
|
||||
directory = os.path.join(settings.SPIP_LOGO_DIR, extension)
|
||||
if not os.access(directory, os.F_OK):
|
||||
try:
|
||||
@ -110,8 +118,8 @@ def fetch_and_remove_logo(article, force_download):
|
||||
SPIP gère les logos à la façon d'un hack : un fichier dans IMG nommé
|
||||
'arton{}.{}'.format(article.pk, ext)
|
||||
"""
|
||||
ext = src.split('.')[-1]
|
||||
filename = 'arton{}.{}'.format(article.pk, ext)
|
||||
extension = get_extension(src)
|
||||
filename = 'arton{}.{}'.format(article.pk, extension)
|
||||
download(src, filename, force_download)
|
||||
|
||||
def remove_img(img):
|
||||
|
Loading…
Reference in New Issue
Block a user