feat(convert): averti en cas d extension de fichier suspecte

master
François Poulain 2 years ago
parent 75eae59ee4
commit ae576d1a38
  1. 14
      drupal2spip_lal/base/convert.py

@ -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…
Cancel
Save