From 2a0e68f72134007e7301ea984a36a98901dcc3f3 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 09:44:48 -1000 Subject: Test DOS line endings and stray lines in cgitrc Without the fold of a carriage return before a newline, repo.path keeps a trailing one and the repository cannot be opened, and no test had a file saved that way. Semicolon comments and a line with no equals sign were untested too. --- tests/t0205-config.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/t0205-config.sh b/tests/t0205-config.sh index 068c390..79a5db0 100755 --- a/tests/t0205-config.sh +++ b/tests/t0205-config.sh @@ -106,6 +106,21 @@ test_expect_success 'a NUL inside a comment does not end it' ' ! grep Smuggled tmp ' +# A file saved with DOS line endings reads as one saved with Unix endings, a +# semicolon starts a comment as a hash does, and a line with no equals sign +# is dropped alone. None of it moves the line a warning names. +test_expect_success 'line endings, comments and stray lines leave the rest alone' ' + printf "%s\r\n" "virtual-root=/" "cache-size=0" "; root-title=Smuggled" \ + "no equals sign here" "repo.url=foo" "repo.path=$PWD/repos/foo/.git" \ + "repo.hide=yes" >crlfrc && + cgit_rc crlfrc "url=foo/" >tmp 2>err && + test_grep "^Status: 200" tmp && + test_grep "data-page=.summary. data-repo=.foo." tmp && + test_grep ! "Smuggled" tmp && + test_grep -F "Reading hide=yes in $PWD/crlfrc line 7 as 0, since it is not a whole number" err && + test_line_count = 1 err +' + # cgitrc and the files it includes are meant to be there, so one that cannot # be read is logged rather than left to show an empty index. test_expect_success 'a config file that cannot be read is reported' ' -- cgit 2.12.1