Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
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.
| -rwxr-xr-x | tests/t0205-config.sh | 15 |
1 file changed, 15 insertions, 0 deletions
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' ' |
