Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Test the include nesting limit
Nothing reached the guard that stops a file including itself, so its
loss would have gone unseen until a site's own cgitrc recursed until
the stack gave out.
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/t0205-config.sh | 28 |
1 file changed, 28 insertions, 0 deletions
diff --git a/tests/t0205-config.sh b/tests/t0205-config.sh index 129b8de..068c390 100755 --- a/tests/t0205-config.sh +++ b/tests/t0205-config.sh @@ -124,6 +124,34 @@ test_expect_success 'a config file that cannot be read is reported' ' grep "Unable to read config file $PWD/no-such-include: No such file or directory" err ' +# An include is parsed from inside the line that names it, so a file that +# includes itself would recurse until the stack gave out. Includes nest eight +# deep below cgitrc, and a ninth is left unread. Each level sets root-desc +# before it includes the next, so the deepest level read is what shows. +test_expect_success 'includes stop at the nesting limit' ' + { + echo "virtual-root=/" && + echo "cache-size=0" && + echo "repo.url=foo" && + echo "repo.path=$PWD/repos/foo/.git" && + echo "include=$PWD/selfrc" + } >selfrc && + cgit_ok selfrc "url=foo/" >tmp && + test_grep "data-page=.summary. data-repo=.foo." tmp && + for level in 1 2 3 4 5 6 7 8 + do + { + echo "root-desc=level $level" && + echo "include=$PWD/level$((level + 1))rc" + } >level${level}rc || return 1 + done && + echo "root-desc=level 9" >level9rc && + cgitrc_repo chainrc foo "include=$PWD/level1rc" && + cgit_ok chainrc "url=" >tmp && + test_grep "level 8" tmp && + test_grep ! "level 9" tmp +' + # A scanned repository's own cgitrc is optional, so a scan says nothing when # one is missing, and neither does reading the scan back from the cache. test_expect_success 'a scan says nothing of the files it may lack' ' |
