From f5fd05461f721ad94fe673e719ecf5eeb7e3a3a1 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 18:38:05 -1000 Subject: Test filter commands without a known prefix --- tests/t0201-filters.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests') diff --git a/tests/t0201-filters.sh b/tests/t0201-filters.sh index d928dec..2c68921 100755 --- a/tests/t0201-filters.sh +++ b/tests/t0201-filters.sh @@ -108,6 +108,22 @@ test_expect_success 'a filter killed by a signal ends the request' ' test_grep -F "Subprocess $PWD/killed-filter exited abnormally" err ' +test_expect_success 'a filter command with no prefix runs as exec' ' + cgitrc_repo bareprefixrc foo "repo.commit-filter=$FILTER_DIRECTORY/dump.sh" && + cgit_ok bareprefixrc "url=foo/commit/" >tmp && + test_grep "
COMMIT 5" tmp +' + +# A prefix that names no kind of filter ends the request rather than leave +# the page unfiltered. +test_expect_success 'a filter command with an unknown prefix ends the request' ' + cgitrc_repo badprefixrc foo "repo.commit-filter=perl:$FILTER_DIRECTORY/dump.sh" && + cgit_rc badprefixrc "url=foo/commit/" >tmp 2>err && + test $(grep -c "^Status:" tmp) = 1 && + test_grep "^Status: 500" tmp && + test_grep -F "Invalid filter type: perl" err +' + # A die inside a lua filter has to reach the visitor as an error page rather # than being fed back into the filter that just failed, and the reason goes to # the log. -- cgit 2.12.1