Metadata removal

master
Bob Mottram 2019-08-02 10:55:45 +01:00
parent 52a4d17512
commit b50252c041
1 changed files with 5 additions and 1 deletions

View File

@ -1656,6 +1656,8 @@ class PubServer(BaseHTTPRequestHandler):
searchStr=b'Content-Type: image/png' searchStr=b'Content-Type: image/png'
imageLocation=postBytes.find(searchStr,lastImageLocation) imageLocation=postBytes.find(searchStr,lastImageLocation)
filenameBase=self.server.baseDir+'/accounts/'+nickname+'@'+self.server.domain+'/'+postKey filenameBase=self.server.baseDir+'/accounts/'+nickname+'@'+self.server.domain+'/'+postKey
# Note: a .temp extension is used here so that at no time is
# an image with metadata publicly exposed, even for a few mS
if imageLocation>-1: if imageLocation>-1:
filename=filenameBase+'.png.temp' filename=filenameBase+'.png.temp'
else: else:
@ -1678,7 +1680,7 @@ class PubServer(BaseHTTPRequestHandler):
startPos+=offset startPos+=offset
break break
# look for the end # look for the end of the image
imageLocationEnd=postBytes.find(b'-------',imageLocation+1) imageLocationEnd=postBytes.find(b'-------',imageLocation+1)
fd = open(filename, 'wb') fd = open(filename, 'wb')
@ -1687,6 +1689,8 @@ class PubServer(BaseHTTPRequestHandler):
else: else:
fd.write(postBytes[startPos:]) fd.write(postBytes[startPos:])
fd.close() fd.close()
# remove exif/metadata
removeMetaData(filename,filename.replace('.temp','')) removeMetaData(filename,filename.replace('.temp',''))
os.remove(filename) os.remove(filename)
lastImageLocation=imageLocation+1 lastImageLocation=imageLocation+1