From eb8818bd4ebaa6394f581798cb9ddb77d19f13d0 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Fri, 28 Sep 2012 17:33:46 -0400 Subject: Transform and validate in _ob_set_*_parameter(). --- diff --git a/lib/package.sh b/lib/package.sh index 938d67c..833bbc7 100644 --- a/lib/package.sh +++ b/lib/package.sh @@ -272,7 +272,14 @@ _ob_set_source_parameter() _obssp_name="${1}" _obssp_value="${2}" - # FIXME: Name transformation and validation? + # Convert field name to uppercase and validate. + _obssp_name="$(echo "${_obssp_name}" | tr 'a-z-' 'A-Z_')" + case "${_obssp_name:- }" in + *[!A-Z0-9_]*) + _ob_return 125 + return ${?} + ;; + esac _OB_SOURCE_PARAMETERS="${_OB_SOURCE_PARAMETERS} ${_obssp_name}" @@ -290,7 +297,23 @@ _ob_set_binary_parameter() _obsbp_name="${2}" _obsbp_value="${3}" - # FIXME: Name transformation and validation? + if ! ob_validate_binary_package_name "${_obsbp_package}"; then + _ob_return 125 + return ${?} + fi + + # Convert package name to its uppercase "clean" form. + _obsbp_package="$(echo "${_obsbp_package}" | tr 'a-z' 'A-Z' | \ + tr -dC 'A-Z0-9')" + + # Convert field name to uppercase and validate. + _obsbp_name="$(echo "${_obsbp_name}" | tr 'a-z-' 'A-Z_')" + case "${_obsbp_name:- }" in + *[!A-Z0-9_]*) + _ob_return 125 + return ${?} + ;; + esac _OB_BINARY_PARAMETERS="${_OB_BINARY_PARAMETERS} ${_obsbp_name}" -- cgit v0.9.1