Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: mark does not work if path contains "[" and "]" #553

Open
pglira opened this issue Dec 16, 2022 · 3 comments · May be fixed by #652
Open

Bug: mark does not work if path contains "[" and "]" #553

pglira opened this issue Dec 16, 2022 · 3 comments · May be fixed by #652
Labels
bug Something isn't working
Milestone

Comments

@pglira
Copy link

pglira commented Dec 16, 2022

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.

@karlch
Copy link
Owner

karlch commented Jan 3, 2023

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?

@karlch karlch added the bug Something isn't working label Jan 3, 2023
@pglira
Copy link
Author

pglira commented Jan 9, 2023

Yes, of course, with this I can try to fix it. Thanks.

@TeaWhyDee
Copy link

TeaWhyDee commented May 27, 2023

Another case:
Filenames with symbols '*', '~', '?' also break marking, using '%m' also breaks
Example: "image.png~"

karlch added a commit that referenced this issue Jul 5, 2023
@karlch karlch added this to the v0.10.0 milestone Jul 15, 2023
karlch added a commit that referenced this issue Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants