From 47a5c008d220fc052590185c5606aaae4728f3b0 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 16:06:48 -1000 Subject: Test request values a page echoes back Only %zz%2 had been sent, so nothing showed that markup in the query, the hidden inputs a form carries, the errors naming a refused value or the Host header is escaped on its way back. --- tests/t0301-security.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'tests') diff --git a/tests/t0301-security.sh b/tests/t0301-security.sh index c9f16a5..40de049 100755 --- a/tests/t0301-security.sh +++ b/tests/t0301-security.sh @@ -554,4 +554,40 @@ test_expect_success 'names and messages holding markup are escaped on every page test_grep ! "" tmp ' +# A page echoes the request in the search box, in the hidden inputs that +# carry a form's state, in the error naming what it refused and, from the +# Host header, in every absolute link. +test_expect_success 'request values echoed into a page are escaped' ' + payload=%27%3E%3Cs%3E && + escaped="'><s>" && + cgit_ok mkrc "url=mk/log/&q=$payload&qt=$payload&id=$payload" >tmp && + test_grep "name=.q. aria-label=.Search. value=.$escaped.>" tmp && + for name in q qt id + do + test_grep "" tmp || return 1 + done && + test_grep ! "" tmp && + cgit_ok mkrc "url=mk/log/&h=br%27%22%3Cx%3E%26" >tmp && + test_grep "" tmp && + test_grep ! "" tmp && + cgit_rc mkrc "url=mk/log/&h=%3Cb%3E" >tmp && + test_grep "
Invalid branch: <b>
" tmp && + cgit_rc mkrc "url=mk/snapshot/%3Cb%3E.zzz" >tmp && + test_grep "
Unsupported snapshot format: <b>.zzz
" tmp && + cgit_rc mkrc "url=mk/blob/%3Cb%3E" >tmp && + test_grep "
Path not found: <b>
" tmp && + test_grep ! "" tmp && + ( + HTTP_HOST="h'\''\"" && + export HTTP_HOST && + cgit_ok mkrc "url=mk/" >tmp && + test_grep "" tmp && + cgit_ok mkrc "url=mk/atom/" >tmp && + test_grep "http://h..<x>/mk/atom/" tmp && + test_grep "" tmp && + test_grep ! "" tmp + ) +' + test_done -- cgit 2.12.1