forked from indymedia/epicyon
Detect start of font file
parent
c7c2866220
commit
7cd33447ca
|
@ -623,6 +623,7 @@ def saveMediaInFormPOST(mediaBytes, debug: bool,
|
||||||
'OTTO': 'application/x-font-opentype'
|
'OTTO': 'application/x-font-opentype'
|
||||||
}
|
}
|
||||||
detectedExtension = None
|
detectedExtension = None
|
||||||
|
isFont = False
|
||||||
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)
|
||||||
|
@ -648,11 +649,15 @@ def saveMediaInFormPOST(mediaBytes, debug: bool,
|
||||||
detectedExtension = 'woff2'
|
detectedExtension = 'woff2'
|
||||||
elif extension == 'OTTO':
|
elif extension == 'OTTO':
|
||||||
detectedExtension = 'otf'
|
detectedExtension = 'otf'
|
||||||
|
isFont = True
|
||||||
break
|
break
|
||||||
|
|
||||||
if not filename:
|
if not filename:
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
|
if isFont:
|
||||||
|
startPos = mediaLocation
|
||||||
|
else:
|
||||||
# locate the beginning of the image, after any
|
# locate the beginning of the image, after any
|
||||||
# carriage returns
|
# carriage returns
|
||||||
startPos = mediaLocation + len(searchStr)
|
startPos = mediaLocation + len(searchStr)
|
||||||
|
|
Loading…
Reference in New Issue