From 9d78b7f285362174e7540c4c035a62ba58d742df Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 17 Nov 2026 14:18:24 +0000 Subject: cgit-about-filter: show errors While a Lua filter is open, cgit hooks its own output into the filter. On a Lua error, cgit's error page ends up in the filter's buffer, so the response ends after
and nothing is logged. Catch errors in filter_close and show them with a traceback. --- pkgs/simple/cgit-about-filter/cgit-about-filter.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'pkgs/simple/cgit-about-filter') diff --git a/pkgs/simple/cgit-about-filter/cgit-about-filter.lua b/pkgs/simple/cgit-about-filter/cgit-about-filter.lua index 8bab6b6..3bbbbcf 100644 --- a/pkgs/simple/cgit-about-filter/cgit-about-filter.lua +++ b/pkgs/simple/cgit-about-filter/cgit-about-filter.lua @@ -312,7 +312,7 @@ function filter_write(str) end end -function filter_close() +local function close() if not should_render then emit("

Error: Access Denied. Only README.md and documentation markdown files are viewable here.

") return @@ -386,3 +386,15 @@ function filter_close() emit("

Error: Could not execute md2html.

") end end + +-- cgit hooks its output into the filter while the filter is open, so the +-- error page of a Lua error in here would end up in the buffer, and the +-- response would end without a word. Show the error instead. +function filter_close() + local ok, err = xpcall(close, debug.traceback) + if not ok then + emit("
")
+        ;(html_txt or io.write)(err)
+        emit("
") + end +end -- cgit v1.3.1