Skip to content

Commit

Permalink
ncp-config: add spaces to invalid characters
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Jul 20, 2018
1 parent baaf79a commit bf91e4c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
4 changes: 3 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
27 changes: 15 additions & 12 deletions etc/library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand All @@ -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
;;
Expand Down

0 comments on commit bf91e4c

Please sign in to comment.