vimiv-qt
vimiv-qt copied to clipboard
Bug: mark does not work if path contains "[" and "]"
It seems that an image can not be marked (with the mark
command or by pressing m
) if the path contains both, an opening and a closing square bracket.
Some examples where marking an image doesn't work ...
/tmp/[a]/image.png
/tmp/[aa]/image.png
and where it works as usual
/tmp/a]/image.png
/tmp/[a/image.png
/tmp/[]/image.png
I've also tested the same paths with round and curly brackets. I observed no issues in these cases.
I can try to fix the issue and submit a PR if somebody can give me a hint where to start.
Thank you for your detailed bug report! I can reproduce the issue, and it seems to be related to pythons globbing module which interprets the content in square brackets.
In vimiv.api.commands
the path expansion is done in the lines 260 following, here with two debug print statements added:
@classmethod
def paths_type(cls, globstr: str) -> typing.List[str]:
"""Retrieve list of paths matching the globstr passed."""
print(escape_glob(globstr))
paths = glob.glob(os.path.expanduser(escape_glob(globstr)), recursive=True)
print(paths)
if not paths:
raise ArgumentError(f"No paths matching '{globstr}'")
return paths
and clearly the brackets are not escaped properly. While we could just use glob.escape
here instead (and this fixes the issue), the function in vimiv.utils
called (escape_glob
) should be fixed in any case (i.e. regex fixed) as we need the different escaping for external commands currently.
Would you like to take a look into this?
Yes, of course, with this I can try to fix it. Thanks.
Another case: Filenames with symbols '*', '~', '?' also break marking, using '%m' also breaks Example: "image.png~"