Start: Correct hash for thumbnail filename

Image file names need to be quoted before hashing to generate thumbnail file names.
This is related to pull requests #4931 and #4972, so please refer to discussions therein.
This commit is contained in:
川島和津実
2021-08-18 22:15:18 +08:00
committed by GitHub
parent 380d214e74
commit 3b6c442187

View File

@@ -109,8 +109,14 @@ def getInfo(filename):
import gnomevfs
except Exception:
# alternative method
import hashlib
fhash = hashlib.md5(("file://"+path).encode("utf8")).hexdigest()
import hashlib,sys
if sys.version_info.major < 3:
import urllib
hashload = urllib.quote("file://"+path,safe=":/")
else:
import urllib.parse
hashload = bytes(urllib.parse.quote("file://"+path,safe=":/"),"ascii")
fhash = hashlib.md5(hashload).hexdigest()
thumb = os.path.join(os.path.expanduser("~"),".thumbnails","normal",fhash+".png")
else:
uri = gnomevfs.get_uri_from_local_path(path)