resurrecting-open-source-projects / scrot

SCReenshOT - command line screen capture utility
Other
495 stars 49 forks source link

fix: bad extension detection #362

Closed N-R-K closed 1 year ago

N-R-K commented 1 year ago

in a command like scrot ~/.local/testfile scrot will incorrectly think that local/testfile is the file extension and thus will try to use it as the output format.

ensure that the extension doesn't contain any slashes to avoid such issues.

N-R-K commented 1 year ago

The thumbnail filename logic (which doesn't use scrotHaveFileExtension()) also suffers from this issue.

https://github.com/resurrecting-open-source-projects/scrot/blob/7ba2528fdb0b0fde8aa6b2e07053252c5317572b/src/options.c#L544

N-R-K commented 1 year ago

Well, it still doesn't quite fix the issue. scrot .dotpic will treat dotpic as the extension but prefixing a filename with . in order to hide them is common in unix-like systems.

So we'll probably want to special case leading . in the basename as well.

N-R-K commented 1 year ago

I think this takes care of all the edge cases (excluding the thumbnail logic which hasn't been touched yet).