From a95e9549a6d7d999dc4c9977579c659ed09b5199 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:27:39 +0800 Subject: [PATCH] Start: Correct hash for thumbnail filename (py3) 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. Only Python3 is supported, not Python2. --- src/Mod/Start/StartPage/StartPage.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/Mod/Start/StartPage/StartPage.py b/src/Mod/Start/StartPage/StartPage.py index bd71fc6bbf..883785e576 100644 --- a/src/Mod/Start/StartPage/StartPage.py +++ b/src/Mod/Start/StartPage/StartPage.py @@ -109,14 +109,8 @@ def getInfo(filename): import gnomevfs except Exception: # alternative method - 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() + import hashlib,urllib.parse + fhash = hashlib.md5(bytes(urllib.parse.quote("file://"+path,safe=":/"),"ascii")).hexdigest() thumb = os.path.join(os.path.expanduser("~"),".thumbnails","normal",fhash+".png") else: uri = gnomevfs.get_uri_from_local_path(path)