From 2982d349731f0ad17b8b895fabfed04e5c4832f4 Mon Sep 17 00:00:00 2001 From: Felix Lohmeier Date: Wed, 20 Apr 2022 09:39:08 +0200 Subject: [PATCH] use complex file name for downloading --- src/lib/init_import.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/lib/init_import.sh b/src/lib/init_import.sh index df2a405..edebae0 100644 --- a/src/lib/init_import.sh +++ b/src/lib/init_import.sh @@ -1,9 +1,7 @@ # common import tasks to support multiple files and URLs # shellcheck shell=bash function init_import() { - local files - local file - local tmpdir + local files file tmpdir # catch args, convert the space delimited string to an array files=() eval "files=(${args[file]})" @@ -13,10 +11,10 @@ function init_import() { # download files if name starts with http:// or https:// for i in "${!files[@]}"; do if [[ ${files[$i]} == "http://"* ]] || [[ ${files[$i]} == "https://"* ]]; then - if ! curl -fs --location "${files[$i]}" >"${tmpdir}/${files[$i]##*/}"; then + if ! curl -fs --location "${files[$i]}" >"${tmpdir}/${files[$i]//[^A-Za-z0-9._-]/_}"; then error "download of ${files[$i]} failed!" fi - files[$i]="${tmpdir}/${files[$i]##*/}" + files[$i]="${tmpdir}/${files[$i]//[^A-Za-z0-9._-]/_}" fi done # create a zip archive if there are multiple files