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