Function xfce_create_shared_thumbnail_path generates filename to hash incorrectly
Hi,
Context
I host a NextCloud WebDAV folder that stores some large files (camera RAW images.) Browsing it over the internet is a nightmare because Thunar tries to download 30MB+ files over WebDAV just to create thumbnails.
To mitigate this, I wrote a script to generate shared-thumbnails according to the FreeDesktop Thumbnail Managing Standard, which Thunar supports since merge thunar!126 (merged) (thunar#262 (closed))
Except it doesn't work :-)
The Problem
On investigation, I've found that the function xfce_create_shared_thumbnail_path
in libxfce4util/xfce-fileutils.c
is using an incorrect version of the filename as input to the MD5 hash that creates the thumbnail path.
The linked spec is clear that the filename hashed should be constructed as path-relative, i.e. including an initial ./
:
For shared thumbnails, you need a canonical URI relative to the shared thumbnail repository, comprised of a single "./"-prefixed and properly encoded path segment for the filename, e.g. "./picture.png". The "./" prefix is required to simplify encoding, and use of the canonical, minimally encoded form of the URI is required to avoid mismatches between thumbnail generator and thumbnail reader. (Emphasis mine)
I.e. you should hash "./picture.png", not "picture.png" as xfce_create_shared_thumbnail_path
does. You can validate this interpretation with the example given in the spec (i.e. the correct hash for a file named "picture.png" is md5("./picture.png")=7fd0e41c1612f860427a76c4100745a3
How to fix...
Obvious answer is obvious - amend xfce_create_shared_thumbnail_path
to prefix the filename with "./" before hashing. It's been a while since I wrote any C, but I'd be happy to create a patch myself and submit it, but given this bug has been floating around for at least a couple of years without anyone noticing, it may be that things have become dependent on the buggy behaviour rather than the specced behaviour, so you may have other opinions. (In the meantime, I've added a "--thunar-compatible" flag to my thumbnail generator script, so no rush from my point of view :-).)