From 74ba1098efd0cd43a5806b4992eec17732330818 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 17 Oct 2026 12:53:18 -1000 Subject: Keep snapshot members from starting at a slash A name that was all suffix, such as .tar, settled on a ref called v with an empty prefix, and an empty snapshot-prefix did the same for a snapshot asked for by id, so every member of the archive started at /. --- tests/t0110-snapshot.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests') diff --git a/tests/t0110-snapshot.sh b/tests/t0110-snapshot.sh index 4852e7b..ec0a0b8 100755 --- a/tests/t0110-snapshot.sh +++ b/tests/t0110-snapshot.sh @@ -146,4 +146,25 @@ test_expect_success 'a real case collision keeps the v on both tags' ' ! grep "vtags-1.0.tar.gz" tmp ' +# A name that is all suffix names no revision, and an empty snapshot-prefix +# gives the members no leading directory rather than a leading slash. +test_expect_success 'a snapshot name with nothing before its suffix is refused' ' + git -C repos/vtags branch v HEAD && + sed "s/^snapshots=tar.gz$/snapshots=tar/" vtagsrc >vtagstarrc && + CGIT_CONFIG="$PWD/vtagstarrc" QUERY_STRING="url=vtags/snapshot/.tar" cgit >tmp && + grep "^Status: 404" tmp +' + +test_expect_success 'an empty snapshot-prefix puts no slash ahead of the members' ' + { + cat vtagstarrc && + echo "repo.snapshot-prefix=" + } >noprefixrc && + CGIT_CONFIG="$PWD/noprefixrc" QUERY_STRING="url=vtags/snapshot/vtags.tar&id=master" cgit >tmp && + strip_headers noprefix.tar && + tar -tf noprefix.tar >members && + grep "^file-1$" members && + ! grep "^/" members +' + test_done -- cgit