File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -246,6 +246,35 @@ is_object_valid() {
246246 fi
247247}
248248
249+ # Check if a object string with key values pairs has the correct format and load it afterwards
250+ parse_object_kv_list () {
251+ local str
252+ local objkv
253+ local suboutput
254+ local OLD_IFS=" $IFS "
255+
256+ str=${@// $' \n ' / }
257+ str=${str// \" / \\\" }
258+ IFS=$' \n '
259+
260+ suboutput=$( sudo -u nobody bash -c " PS4=''; set -xe; eval \" ${str} \" " 2>&1 )
261+ check_result $? " Invalid object format: ${str} " $E_INVALID
262+
263+ for objkv in $suboutput ; do
264+
265+ if [[ " $objkv " =~ ^' eval ' ]]; then
266+ continue
267+ fi
268+
269+ if ! [[ " $objkv " =~ ^([[:alnum:]][_[:alnum:]]{0,64}[[:alnum:]])= (\' ? [^\' ]+? \' ? )? $ ]]; then
270+ check_result $E_INVALID " Invalid key value format [$objkv ]"
271+ fi
272+
273+ eval " $objkv "
274+ done
275+ IFS=" $OLD_IFS "
276+ }
277+
249278# Check if object is supended
250279is_object_suspended () {
251280 if [ $2 = ' USER' ]; then
You can’t perform that action at this time.
0 commit comments