From 0768795ce31c064e06cd4dcd65730eaa71bfef25 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Sun, 26 Jul 2026 10:02:31 +0100 Subject: [PATCH] Test for overlong runs of combining characters, GitHub issue 5434. --- regress/input-common.inc | 14 ++++++++++++++ regress/input-unicode.sh | 4 ++++ regress/tty-draw-line.sh | 22 ++++++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/regress/input-common.inc b/regress/input-common.inc index 100a7be0f..ac04dbc24 100644 --- a/regress/input-common.inc +++ b/regress/input-common.inc @@ -174,3 +174,17 @@ check_raw_matches() fi done } + +check_raw_no_matches() +{ + name=$1 + shift + + capture_raw "$name" >"$TMP" + for unexpected in "$@"; do + if grep -Eq "$unexpected" "$TMP"; then + printf "%s\n" "$unexpected" >"$EXP" + fail "$name raw unexpected" + fi + done +} diff --git a/regress/input-unicode.sh b/regress/input-unicode.sh index ca74a82e8..98c4506e2 100644 --- a/regress/input-unicode.sh +++ b/regress/input-unicode.sh @@ -41,5 +41,9 @@ start_pane combining-left 10 3 '\314\201A\n' check_capture combining-left 'A' check_cursor combining-left '0,1' +start_pane combining-overflow 10 3 'u\314\245\314\245\314\245\314\245\314\245\314\245\314\245\314\245\314\245\314\245\314\245\314\245\314\245\314\245\314\245\314\245\n' +check_raw_matches combining-overflow '^ C 0,0 data=\(1,31,u' +check_raw_no_matches combining-overflow 'data=\(0,' + $TMUX kill-server 2>/dev/null exit $exit_status diff --git a/regress/tty-draw-line.sh b/regress/tty-draw-line.sh index 59331aa0d..09a956312 100644 --- a/regress/tty-draw-line.sh +++ b/regress/tty-draw-line.sh @@ -34,6 +34,18 @@ captureen() { $TMUX capturep -peNS0 -E- >$TMP || exit 1 } +timed() { + if command -v timeout >/dev/null 2>&1; then + timeout 5 "$@" + else + "$@" + fi +} + +capture_timed() { + timed $TMUX capturep -pS0 -E- >$TMP || exit 1 +} + check_line() { line=$1 want=$2 @@ -81,6 +93,8 @@ $TMUX2 neww -d \ "printf '\033(0x\033(B'; exec sleep 100" || exit 1 $TMUX2 neww -d \ "awk 'BEGIN { for (i = 0; i < 1100; i++) printf \"a\" }'; exec sleep 100" || exit 1 +$TMUX2 neww -d \ + "printf 'u\314\245\314\245\314\245\314\245\314\245\314\245\314\245\314\245\314\245\314\245\314\245\314\245\314\245\314\245\314\245\314\245'; exec sleep 100" || exit 1 $TMUX2 selectw -t:0 || exit 1 $TMUX -f/dev/null new -d -x20 -y6 || exit 1 @@ -245,4 +259,12 @@ capture len=$(sed -n 1p $TMP | wc -c) [ "$len" -ge 1100 ] || fail "long same-style line was truncated" +# Too many combining marks on one base character must not leave a standalone +# width-zero cell that can make tty_draw_line loop forever on redraw. +$TMUX resizew -x20 -y6 || exit 1 +timed $TMUX2 selectw -t:13 || fail "zero-width overflow select hung" +sleep 1 +capture_timed +check_grep '^u' + exit 0