fix: pos config secret values corrupted by stray newline in captured input
cfg_read_secret is invoked via $() inside _cfg_edit_one, so the echo that advanced the cursor after hidden input landed on the capture pipe instead of the terminal — every secret value stored with pos config on a real TTY got a leading newline (e.g. AI_GEMINI_API_KEY="\n<key>"), which neither cfg_value nor the ai/telegram load_config parsers could read back: the menu showed '(not set)' and pos ai gemini kept demanding a key. Fix: send that newline to stderr (>&2). Defense in depth: cfg_write and write_config_key now strip CR and truncate multi-line pastes, and the readers (cfg_value, ai + telegram load_config) strip CR. Reproduced and verified on a pseudo-TTY; piped-stdin tests never caught it because non-TTY input skips the stty/echo path.
This commit is contained in:
@@ -25,6 +25,8 @@ config_value() {
|
||||
|
||||
write_config_key() {
|
||||
local key="$1" val="$2" tmp
|
||||
val="${val//$'\r'/}"
|
||||
val="${val%%$'\n'*}"
|
||||
mkdir -p "$CONFIG_DIR"
|
||||
tmp="$(mktemp)"
|
||||
grep -v "^${key}=" "$CONFIG_FILE" 2>/dev/null >"$tmp" || true
|
||||
|
||||
Reference in New Issue
Block a user