소스 검색

nuke: guard against opening risky file types

master
Arun Prakash Jana 5 년 전
부모
커밋
9f7ae0e86a
No known key found for this signature in database GPG 키 ID: A75979F35C080412
1개의 변경된 파일19개의 추가작업 그리고 0개의 파일을 삭제
  1. +19
    -0
      plugins/nuke

+ 19
- 0
plugins/nuke 파일 보기

@@ -18,6 +18,8 @@
# Details:
# 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:
# i. by extension
# ii. by mime (image, video, audio, pdf)
@@ -415,7 +417,24 @@ handle_fallback() {
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}" )"
handle_blocked "${MIMETYPE}"
handle_extension
handle_multimedia "${MIMETYPE}"
handle_mime "${MIMETYPE}"


불러오는 중...
취소
저장