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

Do not quote file paths passed to mailcap entries #239

Merged
merged 1 commit into from
Oct 15, 2021

Conversation

klemensn
Copy link
Contributor

@klemensn klemensn commented Sep 28, 2021

The readme.md example itself uses double-quotes but tg still
shell-escapes/quotes filepaths.

Specifically, mailcap entries like
video/*; mpv --quiet --loop=inf '%s'; test=test -n "$DISPLAY"
would be passed quoted strings for `%s' and create bogus commands like
mpv --quiet ''/path with space.mp4''
effectively breaking the quotes.

NB: This is only a best-effort approach, i.e. file paths are still
shell-escaped in tg's Python code and then passed to NOTIFY_CMD et al.
expecting them to be interpreted by the shell.

It would be best to either

  • pass literal file paths and message/title/etc. strings to external
    commands such that they handle them (possibly being executed directly
    without SHELL), or
  • handle and format the entire command incl. its arguments in tg such
    that correct escaping can be ensured.

@paul-nameless
Copy link
Owner

Thanks for the patch.
I think DEFAULT_OPEN will fail if not quoted, isn't it?

The readme.md example itself uses double-quotes but tg still
shell-escapes/quotes filepaths.

Specifically, mailcap entries like
	video/*; mpv --quiet --loop=inf '%s'; test=test -n "$DISPLAY"
would be passed quoted strings for `%s' and create bogus commands like
	mpv --quiet ''/path with space.mp4''
effectively breaking the quotes.

Leave all quoting to mailcap entries and pass file paths unaltered
to prevent this.

NB:  This is only a best-effort approach, i.e. file paths are still
shell-escaped in tg's Python code and then passed to NOTIFY_CMD et al.
expecting them to be interpreted by the shell.

It would be best to either
- pass literal file paths and message/title/etc. strings to external
  commands such that they handle them (possibly being executed directly
  without SHELL), or
- handle and format the entire command incl. its arguments in tg such
  that correct escaping can be ensured.
@klemensn
Copy link
Contributor Author

klemensn commented Oct 8, 2021

You're right.

I've updated my commit to only avoid quoting for mailcap handled
entries and hopefully clarify the issue a bit further in the commit message.

@paul-nameless paul-nameless merged commit dc7bc80 into paul-nameless:master Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants