Diff options
Diffstat (limited to 'tests/t0301-security.sh')
| -rwxr-xr-x | tests/t0301-security.sh | 39 |
1 file changed, 39 insertions, 0 deletions
diff --git a/tests/t0301-security.sh b/tests/t0301-security.sh index 951cf1e..4df00e7 100755 --- a/tests/t0301-security.sh +++ b/tests/t0301-security.sh @@ -722,4 +722,43 @@ test_expect_success 'a file name of stray bytes is linked percent-encoded' ' test_grep "<div class=.blob-header.>blob: $blob " tmp ' +# A name in UTF-8 is the common case of the same. It goes through the index +# as well, so the tree holds the composed form whatever a filesystem makes +# of the name, and each page shows it as it is, the download name included, +# and links it percent-encoded. +test_expect_success 'a UTF-8 file name is shown as it is and linked percent-encoded' ' + mkrepo repos/utf8 1 && + name=$(printf "caf\303\251.txt") && + encoded=caf%C3%A9.txt && + for content in bonjour "au revoir" + do + blob=$(echo "$content" | git -C repos/utf8 hash-object -w --stdin) && + git -C repos/utf8 update-index --add --cacheinfo "100644,$blob,$name" && + git -C repos/utf8 commit -q -m "$content" || return 1 + done && + old=$(git -C repos/utf8 rev-parse HEAD~1) && + new=$(git -C repos/utf8 rev-parse HEAD) && + cgitrc_repo utf8rc utf8 && + cgit_ok utf8rc "url=utf8/tree/" >tmp && + test_grep "<a class=.ls-blob ext-txt. href=./utf8/tree/$encoded.>$name</a>" tmp && + test_grep "<a class=.button. href=./utf8/plain/$encoded.>plain</a>" tmp && + test_grep ! "href=.[^>]*$name" tmp && + cgit_ok utf8rc "url=utf8/tree/$encoded" >tmp && + test_grep "<title>$name - utf8 - " tmp && + test_grep "/<a href=./utf8/tree/$encoded.>$name</a></span></nav>" tmp && + test_grep "(<a href=./utf8/plain/$encoded.>plain</a>)</div>" tmp && + test_grep "<code>au revoir$" tmp && + test_grep ! "href=.[^>]*$name" tmp && + cgit_ok utf8rc "url=utf8/plain/$encoded" >tmp && + test_grep "^Content-Disposition: inline; filename=.$name.$" tmp && + strip_headers <tmp >body && + echo "au revoir" >expect && + test_cmp expect body && + cgit_ok utf8rc "url=utf8/diff/" >tmp && + test_grep "<td class=.upd.><a href=./utf8/diff/$encoded.>$name</a>" tmp && + test_grep "<div class=.file. data-path=.$name.><div class=.head.>diff --git a/$name b/$name<br>" tmp && + test_grep "<br>--- a/<a href=./utf8/tree/$encoded?id=$old.>$name</a><br>+++ b/<a href=./utf8/tree/$encoded?id=$new.>$name</a>" tmp && + test_grep ! "href=.[^>]*$name" tmp +' + test_done |
