diff options
author | nachoparker <nacho@ownyourbits.com> | 2018-07-20 19:01:06 +0300 |
---|---|---|
committer | nachoparker <nacho@ownyourbits.com> | 2018-07-20 19:36:35 +0300 |
commit | bf91e4c167f0f61e2ab1d87d5be7c5704534f192 (patch) | |
tree | ea0daa5b75e0a95ba0b8888ca6b95d818e65c778 | |
parent | baaf79a3015c7092498eb11cde1d94e562814d45 (diff) |
ncp-config: add spaces to invalid charactersv0.57.20
-rw-r--r-- | changelog.md | 4 | ||||
-rw-r--r-- | etc/library.sh | 27 |
2 files changed, 18 insertions, 13 deletions
diff --git a/changelog.md b/changelog.md index 325863db..a41c1696 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,7 @@ -[v0.57.19](https://github.com/nextcloud/nextcloudpi/commit/acb7114) (2018-07-20) nc-backup: fix space check error message +[v0.57.20](https://github.com/nextcloud/nextcloudpi/commit/0f8bb29) (2018-07-20) ncp-config: add spaces to invalid characters + +[v0.57.19](https://github.com/nextcloud/nextcloudpi/commit/cdefd54) (2018-07-20) nc-backup: fix space check error message [v0.57.18](https://github.com/nextcloud/nextcloudpi/commit/7985f48) (2018-07-13) fix ncc command repeating itself diff --git a/etc/library.sh b/etc/library.sh index 6d9b4a97..40b57fb2 100644 --- a/etc/library.sh +++ b/etc/library.sh @@ -18,8 +18,8 @@ function config() type dialog &>/dev/null || { echo "please, install dialog for interactive configuration"; return 1; } test -f "$INSTALL_SCRIPT" || { echo "file $INSTALL_SCRIPT not found"; return 1; } - local VARS=( $( grep "^[[:alpha:]]\+_=" "$INSTALL_SCRIPT" | cut -d= -f1 | sed 's|_$||' ) ) - local VALS=( $( grep "^[[:alpha:]]\+_=" "$INSTALL_SCRIPT" | cut -d= -f2 ) ) + local VARS=( $( grep "^[[:alpha:]]\+_=" "$INSTALL_SCRIPT" | sed 's|_=.*$||' ) ) + local VALS=( $( grep "^[[:alpha:]]\+_=" "$INSTALL_SCRIPT" | sed 's|^.*_=||' ) ) [[ "$NO_CONFIG" == "1" ]] || test ${#VARS[@]} -eq 0 && { INSTALLATION_CODE="$( cat "$INSTALL_SCRIPT" )"; return; } @@ -35,23 +35,26 @@ function config() while test $RET != 1 && test $RET != 250; do local value - value=$( dialog --ok-label "Start" \ - --no-lines --backtitle "$BACKTITLE" \ - --form "Enter configuration for $( basename "$INSTALL_SCRIPT" .sh )" \ - 20 70 0 $PARAM \ - 3>&1 1>&2 2>&3 ) + value="$( dialog --ok-label "Start" \ + --no-lines --backtitle "$BACKTITLE" \ + --form "Enter configuration for $( basename "$INSTALL_SCRIPT" .sh )" \ + 20 70 0 $PARAM \ + 3>&1 1>&2 2>&3 )" RET=$? - case $RET in $DIALOG_CANCEL) return 1 ;; $DIALOG_OK) - local RET=( $value ) - for i in $( seq 0 1 $(( ${#RET[@]} - 1 )) ); do + local RET_VALS=() + while read l; do RET_VALS+=("$l"); done < <( echo -e "$value" ) + + for i in $( seq 0 1 $(( ${#RET_VALS[@]} - 1 )) ); do + # check for invalid characters - grep -q "[&]" <<< "${RET[$i]}" && { echo "Invalid characters in field ${VARS[$i]}"; return 1; } - local SEDRULE+="s|^${VARS[$i]}_=.*|${VARS[$i]}_=${RET[$i]}|;" + grep -q "[&[:space:]]" <<< "${RET_VALS[$i]}" && { echo "Invalid characters in field ${VARS[$i]}"; return 1; } + + local SEDRULE+="s|^${VARS[$i]}_=.*|${VARS[$i]}_=${RET_VALS[$i]}|;" done break ;; |