sanitize path
This commit is contained in:
parent
63e01692fc
commit
628e5db3f7
11
atom
11
atom
@ -1089,6 +1089,7 @@ copyFile() {
|
||||
}
|
||||
|
||||
sanitizeFile() {
|
||||
shopt -s extglob
|
||||
string="$1"
|
||||
# Filenames can't contain /
|
||||
string="${string//\// }"
|
||||
@ -1106,6 +1107,7 @@ sanitizeFile() {
|
||||
|
||||
# Filenames can't begin or end with ' '
|
||||
string=${string/#+( )/}
|
||||
string=${string/%+( )/}
|
||||
string=${string//+( )./.}
|
||||
string=${string//.+( )/.}
|
||||
fi
|
||||
@ -1133,7 +1135,14 @@ getDestDir() {
|
||||
replace=$(sanitizeFile "$disc")
|
||||
destdir="${destdir//%\{disc\}/$replace}"
|
||||
else
|
||||
destdir+="${filename%/*}"
|
||||
destdir+=(sanitizeFile "${filename%%/*}")
|
||||
part="${filename#*/}/"
|
||||
while :
|
||||
do
|
||||
destdir+="/$(sanitizeFile "${part%%/*}")"
|
||||
part=${part#*/}
|
||||
[ -z "$part" ] && break
|
||||
done
|
||||
fi
|
||||
if ! [ -d "$destdir" ]
|
||||
then
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user