forked from indymedia/epicyon
Detect font binaries
parent
89e7995a33
commit
c7c2866220
20
content.py
20
content.py
|
@ -603,6 +603,7 @@ def saveMediaInFormPOST(mediaBytes, debug: bool,
|
||||||
|
|
||||||
mediaLocation = -1
|
mediaLocation = -1
|
||||||
searchStr = ''
|
searchStr = ''
|
||||||
|
startPos = 0
|
||||||
filename = None
|
filename = None
|
||||||
|
|
||||||
# directly search the binary array for the beginning
|
# directly search the binary array for the beginning
|
||||||
|
@ -616,16 +617,17 @@ def saveMediaInFormPOST(mediaBytes, debug: bool,
|
||||||
'ogv': 'video/ogv',
|
'ogv': 'video/ogv',
|
||||||
'mp3': 'audio/mpeg',
|
'mp3': 'audio/mpeg',
|
||||||
'ogg': 'audio/ogg',
|
'ogg': 'audio/ogg',
|
||||||
'woff': 'application/font-woff',
|
'wOFF': 'application/font-woff',
|
||||||
'woff2': 'application/font-woff2',
|
'wOF2': 'application/font-woff2',
|
||||||
'ttf': 'application/x-font-truetype',
|
'ttf': 'application/x-font-truetype',
|
||||||
'otf': 'application/x-font-opentype'
|
'OTTO': 'application/x-font-opentype'
|
||||||
}
|
}
|
||||||
detectedExtension = None
|
detectedExtension = None
|
||||||
for extension, contentType in extensionList.items():
|
for extension, contentType in extensionList.items():
|
||||||
searchStr = b'Content-Type: ' + contentType.encode('utf8', 'ignore')
|
searchStr = b'Content-Type: ' + contentType.encode('utf8', 'ignore')
|
||||||
mediaLocation = mediaBytes.find(searchStr)
|
mediaLocation = mediaBytes.find(searchStr)
|
||||||
if mediaLocation > -1:
|
if mediaLocation > -1:
|
||||||
|
# image/video/audio binaries
|
||||||
if extension == 'jpeg':
|
if extension == 'jpeg':
|
||||||
extension = 'jpg'
|
extension = 'jpg'
|
||||||
elif extension == 'mpeg':
|
elif extension == 'mpeg':
|
||||||
|
@ -635,6 +637,18 @@ def saveMediaInFormPOST(mediaBytes, debug: bool,
|
||||||
searchStr.decode().split('/')[0].replace('Content-Type: ', '')
|
searchStr.decode().split('/')[0].replace('Content-Type: ', '')
|
||||||
detectedExtension = extension
|
detectedExtension = extension
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
|
# font binaries
|
||||||
|
searchStr = extension.encode('utf8', 'ignore')
|
||||||
|
mediaLocation = mediaBytes.find(searchStr)
|
||||||
|
if mediaLocation > -1:
|
||||||
|
if extension == 'wOFF':
|
||||||
|
detectedExtension = 'woff'
|
||||||
|
elif extension == 'wOF2':
|
||||||
|
detectedExtension = 'woff2'
|
||||||
|
elif extension == 'OTTO':
|
||||||
|
detectedExtension = 'otf'
|
||||||
|
break
|
||||||
|
|
||||||
if not filename:
|
if not filename:
|
||||||
return None, None
|
return None, None
|
||||||
|
|
Loading…
Reference in New Issue