summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2012-09-28 17:33:46 (EDT)
committer P. J. McDermott <pjm@nac.net>2012-09-28 17:33:46 (EDT)
commiteb8818bd4ebaa6394f581798cb9ddb77d19f13d0 (patch)
treeddecb2cba666d852223be4a6251c4d106e8ee573
parent85167af9b748873c4f1ece8a8b109c2d1b08dc40 (diff)
Transform and validate in _ob_set_*_parameter().
-rw-r--r--lib/package.sh27
1 files changed, 25 insertions, 2 deletions
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}"