fix "&" and special characters in filename

This commit is contained in:
Vincent Riquer 2013-05-08 14:30:26 +02:00
parent b3d39239ca
commit 0ae3252665
5 changed files with 18 additions and 10 deletions

2
atom
View File

@ -616,7 +616,7 @@ do
rest=${line#*::AtOM:SQL:Sep::} rest=${line#*::AtOM:SQL:Sep::}
filename=${rest%%::AtOM:SQL:Sep::*} filename=${rest%%::AtOM:SQL:Sep::*}
oldfilename=${rest#*::AtOM:SQL:Sep::} oldfilename=${rest#*::AtOM:SQL:Sep::}
if [[ $oldfilename != $filename ]] && [ -f "$oldfilename" ] if [[ $oldfilename != "$filename" ]] && [ -f "$oldfilename" ]
then then
rm -f "$oldfilename" rm -f "$oldfilename"
fi fi

View File

@ -51,7 +51,12 @@ encodeFile::mp3() {
$( $(
for key in ${!lameopts[@]} for key in ${!lameopts[@]}
do do
echo "cmd_arg$key ${lameopts[key]}" cleanedopts="${lameopts[key]//\&/\\\&}"
cleanedopts="${cleanedopts//\[/\\[}"
cleanedopts="${cleanedopts//\]/\\]}"
cleanedopts="${cleanedopts//\{/\\{}"
cleanedopts="${cleanedopts//\}/\\\}}"
echo "cmd_arg$key $cleanedopts"
done done
) )
cleanup $tempdir/$tmpfile.wav cleanup $tempdir/$tmpfile.wav

View File

@ -26,7 +26,12 @@ encodeFile::opus() {
$( $(
for key in ${!opusencopts[@]} for key in ${!opusencopts[@]}
do do
echo "cmd_arg$key ${opusencopts[key]}" cleanedopts="${opusencopts[key]//\&/\\\&}"
cleanedopts="${cleanedopts//\[/\\[}"
cleanedopts="${cleanedopts//\]/\\]}"
cleanedopts="${cleanedopts//\{/\\{}"
cleanedopts="${cleanedopts//\}/\\\}}"
echo "cmd_arg$key $cleanedopts"
done done
) )
cleanup $tempdir/$tmpfile.wav cleanup $tempdir/$tmpfile.wav

View File

@ -22,6 +22,11 @@ encodeFile::vorbis() {
$( $(
for key in ${!oggencopts[@]} for key in ${!oggencopts[@]}
do do
cleanedopts="${oggencopts[key]//\&/\\\&}"
cleanedopts="${cleanedopts//\[/\\[}"
cleanedopts="${cleanedopts//\]/\\]}"
cleanedopts="${cleanedopts//\{/\\{}"
cleanedopts="${cleanedopts//\}/\\\}}"
echo "cmd_arg$key ${oggencopts[key]}" echo "cmd_arg$key ${oggencopts[key]}"
done done
) )

View File

@ -27,12 +27,5 @@ sanitizeFile() {
string=${string/%+(.)/} string=${string/%+(.)/}
fi fi
fi fi
# Not exactly filename sanitity, but these will make the script fail in
# a decorative way..
string="${string//&/\\&}"
strint="${string//;/\\;}"
# And these would exhibit strange behaviors
string="${string//\[/\\\[}"
string="${string//\]/\\\]}"
echo "$string" echo "$string"
} }