From 61d3eafe98847b9a76ddc04fe7a4f63f341961a4 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sun, 6 Sep 2026 21:40:19 -1000 Subject: Harden the lua filter failure paths --- tests/t0201-filters.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/t0201-filters.sh') diff --git a/tests/t0201-filters.sh b/tests/t0201-filters.sh index a8341aa..8d67c4f 100755 --- a/tests/t0201-filters.sh +++ b/tests/t0201-filters.sh @@ -65,4 +65,26 @@ do " done +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' + +# 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. +test_expect_success CGIT_LUA 'a failing lua filter still renders an error page' ' + cat >broken.lua <<-\EOF && + function filter_open(...) error("boom") end + function filter_write(str) end + function filter_close() return 0 end + EOF + { + echo "cache-size=0" && + echo "repo.url=foo" && + echo "repo.path=$PWD/repos/foo/.git" && + echo "auth-filter=lua:$PWD/broken.lua" + } >brokenrc && + CGIT_CONFIG="$PWD/brokenrc" QUERY_STRING="url=foo/commit" cgit >tmp && + grep "Status: 400" tmp && + grep "Lua error in" tmp +' + test_done -- cgit v2.8.0