From a0480a1376cf327a1e9a6ff8db90c1b37b69223d Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Mon, 19 Jul 2021 07:49:04 +0200 Subject: [PATCH 1/3] Start: Properly hash thumbnail filenames --- src/Mod/Fem/Gui/Resources/ui/Material.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Fem/Gui/Resources/ui/Material.ui b/src/Mod/Fem/Gui/Resources/ui/Material.ui index 818a4f2634..6c5ab1d64c 100755 --- a/src/Mod/Fem/Gui/Resources/ui/Material.ui +++ b/src/Mod/Fem/Gui/Resources/ui/Material.ui @@ -246,7 +246,7 @@ 2.000000000000000 - 2000000000.000000000000000 + 90000000000.000000000000000 Pa From 25e657611860cc8f62873365476401d4ec4d0a3e Mon Sep 17 00:00:00 2001 From: GUAN Xin Date: Tue, 20 Jul 2021 21:19:41 +0800 Subject: [PATCH 2/3] Revert "Start: Properly hash thumbnail filenames" This reverts commit 7e1f48369884647d1bc9eb4e9d7e2062b2897c6c. --- src/Mod/Fem/Gui/Resources/ui/Material.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Fem/Gui/Resources/ui/Material.ui b/src/Mod/Fem/Gui/Resources/ui/Material.ui index 6c5ab1d64c..818a4f2634 100755 --- a/src/Mod/Fem/Gui/Resources/ui/Material.ui +++ b/src/Mod/Fem/Gui/Resources/ui/Material.ui @@ -246,7 +246,7 @@ 2.000000000000000 - 90000000000.000000000000000 + 2000000000.000000000000000 Pa From 9d5e7073509c5ca4cf95dcee0b6b3c5397db223b Mon Sep 17 00:00:00 2001 From: GUAN Xin Date: Wed, 21 Jul 2021 16:49:06 +0800 Subject: [PATCH 3/3] Start: Properly hash thumbnail filenames Image filenames should be encoded as URI before being hashed. Also assume that filenames are already utf8 because the community has been advertiseing utf8 usage since the beginning of this centry. Calling .encode("utf8") on strings that are already in utf8 simply raises the following exception: UnicodeDecodeError: 'ascii' codec can't decode byte ... for non-ascii (already utf8) strings. It's in fact impossible to precisely determine pathname encoding because different components within the path may have different encodings, e.g., a utf8 directory name followed by an MBCS filename is valid on Linux native filesystems. It's the user's responsibility to keep the iocharset consistent. --- src/Mod/Start/StartPage/StartPage.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mod/Start/StartPage/StartPage.py b/src/Mod/Start/StartPage/StartPage.py index 89a30e4e4f..6b11905a0c 100644 --- a/src/Mod/Start/StartPage/StartPage.py +++ b/src/Mod/Start/StartPage/StartPage.py @@ -109,8 +109,8 @@ def getInfo(filename): import gnomevfs except Exception: # alternative method - import hashlib - fhash = hashlib.md5(("file://"+path).encode("utf8")).hexdigest() + import hashlib, urllib + fhash = hashlib.md5(urllib.quote("file://"+path,safe=":/")).hexdigest() thumb = os.path.join(os.path.expanduser("~"),".thumbnails","normal",fhash+".png") else: uri = gnomevfs.get_uri_from_local_path(path)