Browse Source

Also split the file extension on ':' for 'quick' file uploads (THANKS TWITTER)

Wazakindjes 4 years ago
parent
commit
6e50d5c20d
1 changed files with 7 additions and 1 deletions
  1. 7 1
      hurr.py

+ 7 - 1
hurr.py

@@ -291,7 +291,13 @@ if __name__ == "__main__":
 			print "Seems to be a URL too, checkin em sanity lol"
 			try:
 				checkem = urllib2.urlopen(temppath)
-				temppath = "/tmp/%d%s" % (int(time.time()), os.path.splitext(temppath)[1])
+				muhext = os.path.splitext(temppath)[1].strip().lower()
+				if not muhext:
+					raise Exception("unable to parse extension")
+				if "?" in muhext:
+					muhext = muhext.split('?')[0]
+				muhext = muhext.split(':')[0]
+				temppath = "/tmp/%d%s" % (int(time.time()), muhext)
 				with open(temppath, "wb") as tmpf:
 					tmpf.write(checkem.read())
 			except Exception as muherr: