Diff options
| -rwxr-xr-x | tests/t0301-security.sh | 18 |
1 file changed, 18 insertions, 0 deletions
diff --git a/tests/t0301-security.sh b/tests/t0301-security.sh index 4626c2c..229aecb 100755 --- a/tests/t0301-security.sh +++ b/tests/t0301-security.sh @@ -684,4 +684,22 @@ test_expect_success 'robots.txt turns crawlers away from snapshots and blame' ' test_cmp expect rules ' +# A file name may hold any byte but a slash or a NUL, invalid UTF-8 and +# control bytes included, which only reach the tree through the index on a +# filesystem that refuses such names. Escaping is ASCII-based, so they need +# no entity, but a link has to carry them percent-encoded. +test_expect_success 'a file name of stray bytes is linked percent-encoded' ' + mkrepo repos/bytes 1 && + blob=$(git -C repos/bytes rev-parse HEAD:file-1) && + git -C repos/bytes update-index --add --cacheinfo "100644,$blob,$(printf "bad\377name")" && + git -C repos/bytes update-index --add --cacheinfo "100644,$blob,$(printf "ctl\001name")" && + git -C repos/bytes commit -q -m bytes && + cgitrc_repo bytesrc bytes && + cgit_ok bytesrc "url=bytes/tree/" >tmp && + test_grep "href=./bytes/tree/bad%FFname.>" tmp && + test_grep "href=./bytes/tree/ctl%01name.>" tmp && + cgit_ok bytesrc "url=bytes/tree/bad%FFname" >tmp && + test_grep "<div class=.blob-header.>blob: $blob " tmp +' + test_done |
