From 267f9c1550c9c8f803b090c266cabb0cb59efca1 Mon Sep 17 00:00:00 2001 From: 6543 Date: Sat, 9 Feb 2019 04:48:25 +0100 Subject: [PATCH] tool db/import-md5-lsit: handle ' in string --- tools/db/import-md5-list | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/db/import-md5-list b/tools/db/import-md5-list index b95adce..8cd1f51 100755 --- a/tools/db/import-md5-list +++ b/tools/db/import-md5-list @@ -75,11 +75,11 @@ function md5_in_add() { cat $md5list | while read line; do #for each line in md5 local md5=$(echo $line | cut -c -32) local path=$(echo $line | cut -c 33- | sed 's/^\ //g') - local relrevpath=$(echo $path | sed "s|^$moviedir||g" | sed 's|^/||g' | sed 's|/$||g' | rev) + local relrevpath=$(echo $path | sed "s|^$moviedir||g" | sed 's|^/||g' | sed 's|/$||g' | rev | sed "s/'/''/g") #last statement set ' as '' so it wont have an evect in the sql statement local name=$(echo $relrevpath | cut -d '/' -f 1 | rev) local folder=$(echo $relrevpath | cut -d '/' -f 2- | rev) if [ "$(db_query "SELECT COUNT(ID) FROM File WHERE MD5='$md5' AND Folder='$folder' AND Name='$name';")" == "0" ]; then #wenn KEIN gleicher Eintrag Vorhanden - db_query "INSERT INTO File (MD5, Folder, Name, TTSync) VALUES ('$md5', '$folder', '$name', $TTSYNC_EXIST );" #-> handle in future: ";'()" + db_query "INSERT INTO File (MD5, Folder, Name, TTSync) VALUES ('$md5', '$folder', '$name', $TTSYNC_EXIST );" else db_query "UPDATE File SET TTSync=$TTSYNC_EXIST WHERE MD5='$md5' AND Folder='$folder' AND Name='$name';" fi @@ -92,10 +92,10 @@ function md5_rm() { cat $md5list | while read line; do #for each line in md5 local md5=$(echo $line | cut -c -32) local path=$(echo $line | cut -c 33- | sed 's/^\ //g') - local relrevpath=$(echo $path | sed "s|^$moviedir||g" | sed 's|^/||g' | sed 's|/$||g' | rev) + local relrevpath=$(echo $path | sed "s|^$moviedir||g" | sed 's|^/||g' | sed 's|/$||g' | rev | sed "s/'/''/g") #last statement set ' as '' so it wont have an evect in the sql statement local name=$(echo $relrevpath | cut -d '/' -f 1 | rev) local folder=$(echo $relrevpath | cut -d '/' -f 2- | rev) - db_query "DELETE FROM File WHERE MD5='$md5' AND Folder='$folder' AND Name='$name';" #-> handle in future: ";'()" + db_query "DELETE FROM File WHERE MD5='$md5' AND Folder='$folder' AND Name='$name';" done exit 0 @@ -105,14 +105,14 @@ function md5_in_del() { cat $md5list | while read line; do #for each line in md5 local md5=$(echo $line | cut -c -32) local path=$(echo $line | cut -c 33- | sed 's/^\ //g') - local relrevpath=$(echo $path | sed "s|^$moviedir||g" | sed 's|^/||g' | sed 's|/$||g' | rev) + local relrevpath=$(echo $path | sed "s|^$moviedir||g" | sed 's|^/||g' | sed 's|/$||g' | rev | sed "s/'/''/g") #last statement set ' as '' so it wont have an evect in the sql statement local name=$(echo $relrevpath | cut -d '/' -f 1 | rev) local folder=$(echo $relrevpath | cut -d '/' -f 2- | rev) if [ "$(db_query "SELECT COUNT(ID) FROM File WHERE MD5='$md5' AND Folder='$folder' AND Name='$name';")" -gt "0" ]; then #wenn gleicher Eintrag Vorhanden - db_query "UPDATE File SET TTSync=$TTSYNC_DEL WHERE MD5='$md5' AND Folder='$folder' AND Name='$name';" #-> handle in future: ";'()" + db_query "UPDATE File SET TTSync=$TTSYNC_DEL WHERE MD5='$md5' AND Folder='$folder' AND Name='$name';" else #Ansonsten Erstelle Del eintrag - db_query "INSERT INTO File (MD5, Folder, Name, TTSync) VALUES ('$md5', '$folder', '$name', $TTSYNC_DEL );" #-> handle in future: ";'()" + db_query "INSERT INTO File (MD5, Folder, Name, TTSync) VALUES ('$md5', '$folder', '$name', $TTSYNC_DEL );" fi done