From 2278170d29b0c5a61017a99b11b54b3abb92d57f Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Tue, 23 Apr 2019 13:23:52 -0400 Subject: substvars(): Sync with opkbuild --- (limited to 'src') diff --git a/src/substvars.sh b/src/substvars.sh index 36ec308..ee845e3 100644 --- a/src/substvars.sh +++ b/src/substvars.sh @@ -87,9 +87,30 @@ substvars() fi old_rhs="${rhs}" + # Validate the variable name. + case "${name}" in *[!A-Za-z0-9-]* | '') + warn "$(get_msg 'substvar_invalid')" "${name}" + # Remove the variable expansion altogether. We can't + # just leave the variable unexpanded, because the + # presence of the "${" characters would cause this + # parser to loop infinitely. + string="${lhs}${rhs}" + continue + esac + # Perform the substitution. - name="$(printf '%s\n' "${name}" | tr 'A-Z-' 'a-z_')" - value="$(eval "printf '%s\n' \"\${substvar_${name}}\"")" + name_tr="$(printf '%s' "${name}" | tr 'A-Z-' 'a-z_')" + package="$(printf '%s' "${package}" | tr 'A-Z' 'a-z' | \ + tr -dC 'a-z0-9')" + if eval "[ x\"\${substvar_${name_tr}:+set}\" = x'set' ]" + then + name_tr="substvar_${name_tr}" + else + warn "$(get_msg 'substvar_unknown')" "${name}" + string="${lhs}${rhs}" + continue + fi + value="$(eval "printf '%s' \"\${${name_tr}}\"")" string="${lhs}${value}${rhs}" depth=$((${depth} + 1)) done -- cgit v0.9.1