From 3b6c44218720d7cc029ef4a8d8a9306f52d3ecf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B7=9D=E5=B3=B6=E5=92=8C=E6=B4=A5=E5=AE=9F?= Date: Wed, 18 Aug 2021 22:15:18 +0800 Subject: [PATCH] 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. --- src/Mod/Start/StartPage/StartPage.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Mod/Start/StartPage/StartPage.py b/src/Mod/Start/StartPage/StartPage.py index 89a30e4e4f..bd71fc6bbf 100644 --- a/src/Mod/Start/StartPage/StartPage.py +++ b/src/Mod/Start/StartPage/StartPage.py @@ -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)