sanitize path

This commit is contained in:
Vincent Riquer 2013-04-02 00:02:42 +02:00
parent 63e01692fc
commit 628e5db3f7

11
atom
View File

@ -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