Can't open files with special characters in their name: the file Uri is wrong
Given a file with a special character in its name, e.g. a "hash" : "/tmp/whatever #foo.png"
Then Catfish will be able to list it but not open it (directly).
We fallback on the "Select Application" menu where the first choice is the default app.
Pressing Enter then opens the file, proving the app is already correctly associated with this file type.
In CatfishWindow.py, we see this:
else:
try:
uri = "file://" + filename
Gio.AppInfo.launch_default_for_uri(uri)
except:
self.on_menu_open_with_activate(self)
return
I changed the except part to this:
except Exception as e:
print("The error is: ", e)
self.on_menu_open_with_activate(self)
And saw this exception:
g-io-error-quark: Error when getting information for file “'file:///tmp/whatever ”: No such file or directory (1)
Which means the uri is wrong and we go to self.on_menu_open_with_activate(self)
.
One of the following methods could be used to build a correct uri:
import pathlib
...
uri = pathlib.Path(filename).as_uri()
import urllib.parse
import urllib.request
...
uri = urllib.parse.urljoin("file://", urllib.request.pathname2url(filename))