Skip to content

Commit 90416b8

Browse files
committed
library.sh: Support parameters with 'allow_unsafe'
elements.php: Replace '%SPACE%' with ' ' for parameters with 'allow_unsafe'
1 parent ee968cb commit 90416b8

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

etc/library.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,13 @@ function configure_app()
7373
$DIALOG_OK)
7474
while read val; do local ret_vals+=("$val"); done <<<"$value"
7575

76+
local allow_unsafe
77+
7678
for (( i = 0 ; i < len ; i++ )); do
7779
# check for invalid characters
80+
# check if unsafe characters (spaces) are allowed (will return 'null' if key not found)
81+
allow_unsafe="$(jq -r .params[$i].allow_unsafe <<<"$cfg")"
82+
[[ "${allow_unsafe}" == 'true' ]] && ret_vals[$i]="${ret_vals[$i]// /%SPACE%}"
7883
grep -q '[\\&#;'"'"'`|*?~<>^"()[{}$&[:space:]]' <<< "${ret_vals[$i]}" && { echo "Invalid characters in field ${vars[$i]}"; return 1; }
7984

8085
cfg="$(jq ".params[$i].value = \"${ret_vals[$i]}\"" <<<"$cfg")"

ncp-web/elements.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ function print_config_form( $ncp_app, $cfg, $l )
2424
$ret .= "<td><label for=\"$ncp_app-$param[id]\">$param[name]</label></td>";
2525

2626
$value = $param['value'];
27+
if (array_key_exists('allow_unsafe', $param) && $param['allow_unsafe'] == "true")
28+
$value = str_replace("%SPACE%", " ", $value);
2729
if ( $value == '_')
2830
$value = '';
2931

0 commit comments

Comments
 (0)