diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-17 08:15:35 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-17 08:15:35 +0300 |
| commit | 50d951ab3bb28861b34bc190911dd76bfb93e71c (patch) | |
| tree | d78bfe5a1620502fca10e78fc0328092d408742e /src/lib/config.sync.source.sh | |
| parent | ca5bcf37e40d4dbd41dc9d9d001d6f4b9c6dcd65 (diff) | |
bn0 guard preview_num arithmetic against non-numeric input
The preview_num next/prev render handlers computed neighbour page numbers
with $(( context_value +/- 1 )) but only guarded against an empty value.
A non-numeric preview_num context value (e.g. a stray string) slipped past
the [ -n ] check and triggered a bash arithmetic syntax error which, under
set -e, aborted the whole script.
Validate the context value is a non-negative integer
([[ value =~ ^[0-9]+$ ]]) before the arithmetic in both
prepare_template_render_var__preview_num_next_html and __preview_num_prev_html.
Invalid or missing values now default to an empty render value, matching the
existing missing-neighbour behaviour; the valid-numeric path is unchanged.
Add test_template_render_var_preview_num_guards_non_numeric in tests/cli.sh,
which drives the handlers directly under bash -euo pipefail to prove a bad
preview_num no longer crashes and a numeric one still yields the exact
+1 / -1 neighbour.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'src/lib/config.sync.source.sh')
0 files changed, 0 insertions, 0 deletions
