1$" tmp
'
# A repository served as html runs its pages on the site's own origin, so
# the switch waits on trust like the keys that place markup. The warning has
# to name the repository, which it did not for a key read from git config.
test_expect_success 'html serving from a scanned repository waits on trust' '
mkrepo repos/html 1 &&
test_commit -C repos/html --no-tag html page.html "page
" &&
mkdir -p scan2 &&
git clone -q --bare repos/html/.git scan2/c.git &&
git -C scan2/c.git config cgit.enable-html-serving 1 &&
{
echo "virtual-root=/" &&
echo "cache-size=0" &&
echo "enable-git-config=1" &&
echo "mimetype.html=text/html" &&
echo "scan-path=$PWD/scan2"
} >htmlrc &&
cgit_rc htmlrc "url=c.git/plain/page.html" >tmp 2>err &&
grep "^Content-Type: text/plain" tmp &&
grep "^X-Content-Type-Options: nosniff" tmp &&
grep "Ignoring enable-html-serving in $PWD/scan2/c.git/: trust-scan-config is not set" err
'
# The repository and config are the ones the test above set up.
test_expect_success 'with trust-scan-config the same repository serves html' '
{
echo "trust-scan-config=1" &&
cat htmlrc
} >htmltrustrc &&
cgit_rc htmltrustrc "url=c.git/plain/page.html" >tmp &&
grep "^Content-Type: text/html" tmp &&
! grep "^X-Content-Type-Options" tmp
'
test_expect_success SYMLINKS 'a symlink cycle under the scan path is entered once' '
mkdir loopscan &&
git clone -q --bare repos/rob/.git loopscan/r.git &&
ln -s . loopscan/loop &&
{
echo "virtual-root=/" &&
echo "cache-size=0" &&
echo "scan-path=$PWD/loopscan"
} >looprc &&
cgit_ok looprc "url=" >tmp &&
test_grep "r.git" tmp &&
test $(grep -c " | " tmp) = 1
'
test_expect_success 'a bare query parameter does not swallow the next one' '
cgit_rc robrc "url=rob/commit/&x&id=$sha" >tmp &&
grep "commit 2" tmp
'
# Whether cgit first sees the filter's exit status or its closed pipe
# depends on which side runs first, so either message will do.
test_expect_success 'a filter that cannot run answers one error page' '
{
echo "commit-filter=exec:$PWD/no/such/filter" &&
cat robrc
} >badfilterrc &&
cgit_rc badfilterrc "url=rob/commit/" >tmp 2>err &&
test $(grep -c "^Status:" tmp) = 1 &&
grep "Unable to complete the request" tmp &&
grep -e "Unable to run filter $PWD/no/such/filter" -e "Unable to write the page" err &&
grep "Unable to exec filter" err
'
# The filter may exit before or after cgit writes to it, so the page either
# completes or ends where the write failed. Either way cgit answers once and
# exits cleanly rather than dying of SIGPIPE. The file outgrows the pipe, so
# the write has to block and then fail however the two sides are scheduled.
test_expect_success 'a filter that exits without reading does not end cgit' '
mkrepo repos/quit 1 &&
test_seq 20000 >repos/quit/big.txt &&
git -C repos/quit add big.txt &&
git -C repos/quit commit -q -m big &&
cgitrc_repo quitrc quit source-filter=exec:true &&
cgit_rc quitrc "url=quit/tree/big.txt" >tmp 2>err &&
test $(grep -c "^Status:" tmp) = 1 &&
test_grep "