From 5d8d667e0474c7e404c4936652fc29fb679f00c9 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 15:40:17 -1000 Subject: Test the snapshot slash rule on a real ref Every candidate name meets check_refname_format first, which refuses the old payload, so the slash rule never answered it and could go unnoticed. A tag holding a slash reaches it, and a name in revision syntax without a slash now pins the ref name check of its own. --- tests/t0303-robustness.sh | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/tests/t0303-robustness.sh b/tests/t0303-robustness.sh index 5f247d1..c0e7c96 100755 --- a/tests/t0303-robustness.sh +++ b/tests/t0303-robustness.sh @@ -247,11 +247,27 @@ test_expect_success 'a path below the about page answers 404' ' grep "^Status: 404" tmp ' +# The stem becomes the leading directory of every member of the archive, so +# a name holding a slash is refused even where it spells a ref. Such a ref +# is linked under a dashed name instead. test_expect_success 'a snapshot name holding a slash is refused' ' - cgit_rc robrc "url=rob/snapshot/:/../../...tar.gz" >tmp && - grep "^Status: 404" tmp && - cgit_rc robrc "url=rob/snapshot/rob-master.tar.gz" >tmp && - grep "^Status: 200" tmp + git -C repos/rob tag rel/1 && + test_when_finished "git -C repos/rob tag -d rel/1" && + for name in rel/1 :/../../.. + do + cgit_rc robrc "url=rob/snapshot/$name.tar.gz" >tmp && + test_grep "^Status: 404" tmp || return 1 + done && + cgit_ok robrc "url=rob/snapshot/rob-master.tar.gz" >tmp +' + +# Only a ref is worked back from a file name, since the wider revision syntax +# can walk the whole history for a match. The name holds no slash, so it +# reaches that check rather than the one above. +test_expect_success 'a snapshot name in revision syntax is refused' ' + cgit_rc robrc "url=rob/snapshot/master~1.tar.gz" >tmp && + test_grep "^Status: 404" tmp && + cgit_ok robrc "url=rob/snapshot/master.tar.gz" >tmp ' test_expect_success 'a path opening with a colon is refused on the log and patch pages' ' -- cgit 2.12.1