Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Percent-encode a submodule path in its link
A module-link template takes the path as the tree names it, so a path
holding a space or a byte past ASCII gave an href that broke there. The
url is now encoded the way a clone url is.
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/t0202-submodule-links.sh | 18 |
1 file changed, 18 insertions, 0 deletions
diff --git a/tests/t0202-submodule-links.sh b/tests/t0202-submodule-links.sh index ffe10de..7e43c67 100755 --- a/tests/t0202-submodule-links.sh +++ b/tests/t0202-submodule-links.sh @@ -177,6 +177,24 @@ test_expect_success 'the module-link templates win over .gitmodules' ' ! grep "subtarget/tree" tmp ' +# A template takes the path as the tree names it, so a space or a byte past +# ASCII in a path has to be percent-encoded before an href can carry it. +test_expect_success 'a module-link template percent-encodes the path' ' + sub=$(git -C repos/subtarget rev-parse HEAD) && + git init -q repos/oddsub && + ( + cd repos/oddsub && + git update-index --add --cacheinfo "160000,$sub,my lib" && + git update-index --add --cacheinfo "160000,$sub,$(printf "caf\303\251")" && + git commit -q -m "odd submodule paths" + ) && + cgitrc_repo oddrc oddsub "module-link=/mods/%s/%s" && + cgit_ok oddrc "url=oddsub/tree/" >tmp && + grep "<a class=.ls-mod. href=./mods/my%20lib/$sub.>my lib</a>" tmp && + grep "<a class=.ls-mod. href=./mods/caf%C3%A9/$sub.>caf" tmp && + ! grep "href=./mods/my lib/" tmp +' + test_expect_success 'the links stay off without the flag' ' cgitrc_repo suboffrc subparent && cgit_ok suboffrc "url=subparent/tree/" >tmp && |
