From b50252c041a1c271a0294c8e9d42d4746f40a2f1 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 2 Aug 2019 10:55:45 +0100 Subject: [PATCH] Metadata removal --- daemon.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/daemon.py b/daemon.py index 42c5c506..17fd85a1 100644 --- a/daemon.py +++ b/daemon.py @@ -1656,6 +1656,8 @@ class PubServer(BaseHTTPRequestHandler): searchStr=b'Content-Type: image/png' imageLocation=postBytes.find(searchStr,lastImageLocation) 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: filename=filenameBase+'.png.temp' else: @@ -1678,7 +1680,7 @@ class PubServer(BaseHTTPRequestHandler): startPos+=offset break - # look for the end + # look for the end of the image imageLocationEnd=postBytes.find(b'-------',imageLocation+1) fd = open(filename, 'wb') @@ -1687,6 +1689,8 @@ class PubServer(BaseHTTPRequestHandler): else: fd.write(postBytes[startPos:]) fd.close() + + # remove exif/metadata removeMetaData(filename,filename.replace('.temp','')) os.remove(filename) lastImageLocation=imageLocation+1