allow jsshDB files in BASHBOT_DATA also

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2020-05-14 22:00:05 +02:00
parent 1e0de91a2d
commit 64efe96117
2 changed files with 7 additions and 5 deletions

View File

@ -464,9 +464,9 @@ Usually message is automatically forwarded in 'commands.sh', but you can forwar
### jsshDB
Since output generated by JSON.sh is so handy to use in bash, we use the format for a simple keys/value storage and providing
fucntions to read and write JSON.sh style data from and to files.
The file extions is '.jssh' and for security reasons location of jssh files is restricted to BASHBOT_ETC.
The file extions is '.jssh' and for security reasons location of jssh files is restricted to BASHBOT_ETC and BASHBOT_DATA..
Note: File names containg '..' and absolute file names pointing outside BASHBOT_ETC are refused by jsshDB functions.
Note: File names containg '..' and absolute file names pointing outside BASHBOT_ETC or BASHBOT_DATA are refused by jsshDB functions.
*Example:* for file name:
@ -935,5 +935,5 @@ The name of your bot is availible as bash variable "$ME", there is no need to ca
#### [Prev Best Practice](5_practice.md)
#### [Next Notes for Developers](7_develop.md)
#### $$VERSION$$ v0.94-pre-0-gac2ec02
#### $$VERSION$$ v0.94-pre-6-g1e0de91

View File

@ -5,7 +5,7 @@
# This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
#
#### $$VERSION$$ v0.94-pre-2-gc0a633f
#### $$VERSION$$ v0.94-pre-6-g1e0de91
#
# source from commands.sh to use jsonDB functions
#
@ -100,7 +100,9 @@ jssh_newDB() {
jssh_checkDB(){
[ -z "$1" ] && return 1
local DB="${BASHBOT_ETC:-.}/$1.jssh"
[[ "$1" = "${BASHBOT_ETC:-.}"* ]] && DB="$1.jssh"
if [[ "$1" = "${BASHBOT_ETC:-.}"* ]] || [[ "$1" = "${BASHBOT_DATA:-.}"* ]]; then
DB="$1.jssh"
fi
[[ "$1" = *'..'* ]] && return 2
printf '%s\n' "${DB}"
}