Tidying of image formats

merge-requests/30/head
Bob Mottram 2021-07-01 10:51:16 +01:00
parent 36303ab578
commit 0627c10996
2 changed files with 11 additions and 6 deletions

View File

@ -256,6 +256,7 @@ from utils import saveJson
from utils import isSuspended
from utils import dangerousMarkup
from utils import refreshNewswire
from utils import isImageFile
from manualapprove import manualDenyFollowRequest
from manualapprove import manualApproveFollowRequest
from announce import createAnnounce
@ -13235,12 +13236,7 @@ class PubServer(BaseHTTPRequestHandler):
print('DEBUG: no media filename in POST')
if filename:
if filename.endswith('.png') or \
filename.endswith('.jpg') or \
filename.endswith('.webp') or \
filename.endswith('.avif') or \
filename.endswith('.svg') or \
filename.endswith('.gif'):
if isImageFile(filename):
postImageFilename = filename.replace('.temp', '')
print('Removing metadata from ' + postImageFilename)
city = getSpoofedCity(self.server.city,

View File

@ -270,6 +270,15 @@ def getImageFormats() -> str:
return imageFormats
def isImageFile(filename: str) -> bool:
"""Is the given filename an image?
"""
for ext in getImageExtensions():
if filename.endswith('.' + ext):
return True
return False
def getMediaFormats() -> str:
"""Returns a string of permissable media formats
used when selecting an attachment for a new post