diff options
author | P. J. McDermott <pjm@nac.net> | 2012-10-26 02:25:59 (EDT) |
---|---|---|
committer | P. J. McDermott <pjm@nac.net> | 2012-10-26 02:25:59 (EDT) |
commit | 000a27ffc3f239b457487f5db479d1e7282e3ad5 (patch) | |
tree | f5e53d174963d47b6752ad0dbe0ec98be4ba1562 /lib | |
parent | 871bafacd57c4c0ef86c0cadd72ecbabedae05a5 (diff) |
Validate substvar names.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/control.sh | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/control.sh b/lib/control.sh index 04a0cba..746863e 100644 --- a/lib/control.sh +++ b/lib/control.sh @@ -157,6 +157,15 @@ ob_set_substvar() return ${?} fi + # Convert variable name to uppercase and validate. + _obssv_name="$(echo "${_obssv_name}" | tr 'a-z-' 'A-Z_')" + case "${_obssv_name:- }" in + *[!A-Z0-9_]*) + _ob_return 125 + return ${?} + ;; + esac + # Trim leading and trailing whitespace from value. _obssv_value="$(echo "${_obssv_value}" | sed -n ' H; # Store each input line in the hold space. @@ -168,7 +177,6 @@ ob_set_substvar() }; ')" - _obssv_name="$(echo "${_obssv_name}" | tr 'a-z-' 'A-Z_')" eval "_OB_SUBSTVAR_${_obssv_name}='${_obssv_value}'" _ob_return 125 |