From e8671e5f11c1d64d539cf4677808e7617c94d050 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Fri, 16 Oct 2026 06:36:07 -1000 Subject: Hand the about filter the tree url its links need With nothing below the about page, a readme's relative links have to be written against the tree, and only cgit knows how this site spells the url of a tree page and which ref the readme was read from. Both reach the filter already escaped for a url, built by the same writer as cgit's own links. --- tests/t0201-filters.sh | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'tests/t0201-filters.sh') diff --git a/tests/t0201-filters.sh b/tests/t0201-filters.sh index 11fa5f8..c6b23af 100755 --- a/tests/t0201-filters.sh +++ b/tests/t0201-filters.sh @@ -30,7 +30,7 @@ do " test_expect_success "check whether the $prefix about filter works" ' - grep "
a+b HELLO$" tmp + grep "
a+b /filter-$prefix/tree/ HELLO$" tmp ' test_expect_success "generate filter-$prefix/commit/" " @@ -61,10 +61,32 @@ do test_expect_success "the $prefix about filter output stays inside its div" " cgit_url 'filter-$prefix/about/' >tmp && - grep \"
a+b HELLO\" tmp + grep \"
a+b /filter-$prefix/tree/ HELLO\" tmp " done +# A readme read at another branch links into the tree at that branch, which +# the filter is told as the query to follow a path with. +test_expect_success 'the about filter gets the tree url at the readme branch' ' + { + echo "virtual-root=/" && + echo "cache-size=0" && + echo "readme=:a+b" && + echo "about-filter=exec:$FILTER_DIRECTORY/dump.sh" && + echo "root-readme=$PWD/root.txt" && + echo "repo.url=filtered" && + echo "repo.path=$PWD/repos/filter/.git" + } >aboutargsrc && + CGIT_CONFIG="$PWD/aboutargsrc" QUERY_STRING="url=filtered/about/&h=1%2b2" cgit >tmp && + grep "
a+b /filtered/tree/ ?h=1%2B2 HELLO" tmp +' + +test_expect_success 'the site readme leaves the tree url empty' ' + echo site >root.txt && + CGIT_CONFIG="$PWD/aboutargsrc" QUERY_STRING="p=about" cgit >tmp && + grep "root.txt SITE" tmp +' + test "$CGIT_HAS_LUA" -eq 1 && test_set_prereq CGIT_LUA test "$CGIT_HAS_LUA" -eq 1 || say 'cgit built without lua, error page check skipped' -- cgit