mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
nuke: guard against opening risky file types
This commit is contained in:
parent
88b8d2641d
commit
9f7ae0e86a
19
plugins/nuke
19
plugins/nuke
|
@ -18,6 +18,8 @@
|
||||||
# Details:
|
# Details:
|
||||||
# Inspired by ranger's scope.sh, modified for usage with nnn.
|
# Inspired by ranger's scope.sh, modified for usage with nnn.
|
||||||
#
|
#
|
||||||
|
# Guards against accidentally opening mime types like executables, shared libs etc.
|
||||||
|
#
|
||||||
# Tries to play 'file' (1st argument) in the following order:
|
# Tries to play 'file' (1st argument) in the following order:
|
||||||
# i. by extension
|
# i. by extension
|
||||||
# ii. by mime (image, video, audio, pdf)
|
# ii. by mime (image, video, audio, pdf)
|
||||||
|
@ -415,7 +417,24 @@ handle_fallback() {
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handle_blocked() {
|
||||||
|
case "${MIMETYPE}" in
|
||||||
|
application/x-sharedlib)
|
||||||
|
exit 0;;
|
||||||
|
|
||||||
|
application/x-shared-library-la)
|
||||||
|
exit 0;;
|
||||||
|
|
||||||
|
application/x-executable)
|
||||||
|
exit 0;;
|
||||||
|
|
||||||
|
application/x-shellscript)
|
||||||
|
exit 0;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
MIMETYPE="$( file --dereference --brief --mime-type -- "${FPATH}" )"
|
MIMETYPE="$( file --dereference --brief --mime-type -- "${FPATH}" )"
|
||||||
|
handle_blocked "${MIMETYPE}"
|
||||||
handle_extension
|
handle_extension
|
||||||
handle_multimedia "${MIMETYPE}"
|
handle_multimedia "${MIMETYPE}"
|
||||||
handle_mime "${MIMETYPE}"
|
handle_mime "${MIMETYPE}"
|
||||||
|
|
Loading…
Reference in a new issue