Skip to content

Commit

Permalink
new: validate groups when creating new test
Browse files Browse the repository at this point in the history
Allow only lower case letters, digits, spaces and underscore when
adding groups, give prompt if there's any not-allowed characters.
Also remove redundant spaces between groups.

Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
  • Loading branch information
Eryu Guan committed Aug 3, 2017
1 parent fed9041 commit 9c129c6
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions new
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ then

while true
do
echo -n "Add to group(s) [other] (? for list): "
echo -n "Add to group(s) [other] (separate by space, ? for list): "
read ans
[ -z "$ans" ] && ans=other
if [ "X$ans" = "X?" ]
Expand All @@ -254,7 +254,17 @@ then
lst=`for word in $grpl; do echo $word; done | sort| uniq `
echo $lst
else
break
# only allow lower cases, spaces, digits and underscore in group
inval=`echo $ans | tr -d '[:lower:][:space:][:digit:]_'`
if [ "$inval" != "" ]; then
echo "Invalid characters in group(s): $inval"
echo "Only lower cases, digits and underscore are allowed in groups, separated by space"
continue
else
# remove redundant spaces/tabs
ans=`echo "$ans" | sed 's/\s\+/ /g'`
break
fi
fi
done
else
Expand Down

0 comments on commit 9c129c6

Please sign in to comment.