From d2de34528dd9ed67957b09b294abb28154d4a4c6 Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Wed, 25 Feb 2026 21:02:08 +0100 Subject: revert(preset): return ffargs via nameref instead of global variable Reverts commit b10b81fefbe529be7db14ca65ec4b4a293782d39. The nameref approach did not work as intended; reverting to restore correct behaviour. --- transcode.sh | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/transcode.sh b/transcode.sh index 527c15c..a5a91d8 100755 --- a/transcode.sh +++ b/transcode.sh @@ -347,10 +347,6 @@ fi # Load ffmpeg argument preset by name. # -# Arguments: -# $1 - preset name -# $2 - name of the caller's array variable to populate (nameref) -# # Security: # Presets are sourced as shell code. Names are validated against a strict # allowlist (alphanumerics, hyphens, underscores only) to prevent path @@ -362,12 +358,8 @@ fi # The sourced preset MUST set the bash array `ffargs`. # Presets may reference variables from the caller (encode_one) such as: # output_pixel_format, input_pixel_format, input_codec -# On return the caller's array (named by $2) is populated with the preset's -# ffargs; the preset-local `ffargs` variable is unset before returning. load_preset() { local preset="$1" - local -n _load_preset_out="$2" - # Strict allowlist: only alphanumerics, hyphens, and underscores are permitted. # This prevents path traversal, shell metacharacter injection, and symlink-based # attacks more reliably than a blocklist approach. @@ -397,7 +389,8 @@ load_preset() { exit $EXIT_CONFIG_ERROR fi - local ffargs=() + unset -v ffargs + ffargs=() debug "Sourcing preset file:" "$file" @@ -410,8 +403,6 @@ load_preset() { } debug "Preset ffargs:" "$(printf "%q " "${ffargs[@]}")" - - _load_preset_out=("${ffargs[@]}") } if [[ $# -eq 0 ]]; then @@ -705,10 +696,7 @@ encode_one() { output_pixel_format="yuv${subsampling}${depth}" debug "Selected output pixel format:" "$output_pixel_format" - # Load preset early so a missing/invalid preset fails before we create a - # temp file or do any further work. - local ffargs=() - load_preset "$PRESET_NAME" ffargs + load_preset "$PRESET_NAME" local extension directory tmp base stem # filename (path without extension) is used only for the savings log. -- cgit v1.3.1