From 735aca5b44e8d731463b8f04b850de2b4b3d2df7 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Tue, 12 Mar 2019 16:50:27 -0400 Subject: *ob_[gs]et_*_parameter(): Make validation more immediately clear --- (limited to 'lib') diff --git a/lib/package.sh b/lib/package.sh index 99f7b76..5111341 100644 --- a/lib/package.sh +++ b/lib/package.sh @@ -227,12 +227,10 @@ ob_get_source_parameter() fi # Convert field name to uppercase and validate. - name="$(echo "${name}" | tr 'a-z-' 'A-Z_')" - case "${name:- }" in - *[!A-Z0-9_]*) - return 125 - ;; + case "${name}" in *[!A-Za-z0-9-]* | '') + return 125 esac + name="$(echo "${name}" | tr 'a-z-' 'A-Z_')" eval "printf '%s' \"\${_OB_SRCFIELD_${name}}\"" @@ -260,12 +258,10 @@ ob_get_binary_parameter() tr -dC 'A-Z0-9')" # Convert field name to uppercase and validate. - name="$(echo "${name}" | tr 'a-z-' 'A-Z_')" - case "${name:- }" in - *[!A-Z0-9_]*) - return 125 - ;; + case "${name}" in *[!A-Za-z0-9-]* | '') + return 125 esac + name="$(echo "${name}" | tr 'a-z-' 'A-Z_')" eval "printf '%s' \"\${_OB_BINFIELD_${package}_${name}}\"" @@ -357,12 +353,10 @@ _ob_set_source_parameter() value="${2}" # Convert field name to uppercase and validate. - name="$(echo "${name}" | tr 'a-z-' 'A-Z_')" - case "${name:- }" in - *[!A-Z0-9_]*) - return 125 - ;; + case "${name}" in *[!A-Za-z0-9-]* | '') + return 125 esac + name="$(echo "${name}" | tr 'a-z-' 'A-Z_')" _OB_SOURCE_PARAMETERS="${_OB_SOURCE_PARAMETERS} ${name}" @@ -390,12 +384,10 @@ _ob_set_binary_parameter() tr -dC 'A-Z0-9')" # Convert field name to uppercase and validate. - name="$(echo "${name}" | tr 'a-z-' 'A-Z_')" - case "${name:- }" in - *[!A-Z0-9_]*) - return 125 - ;; + case "${name}" in *[!A-Za-z0-9-]* | '') + return 125 esac + name="$(echo "${name}" | tr 'a-z-' 'A-Z_')" if ! echo " ${_OB_BINARY_PARAMETERS} " | grep " ${name} " \ >/dev/null 2>&1; then -- cgit v0.9.1