paul-nameless / tg

terminal telegram client
The Unlicense
943 stars 75 forks source link

Do not quote file paths passed to mailcap entries #239

Closed klemensn closed 3 years ago

klemensn commented 3 years ago

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

paul-nameless commented 3 years ago

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

klemensn commented 3 years ago

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.