diff options
Diffstat (limited to '')
-rwxr-xr-xtests/t0501-about-render.sh21
1 file changed, 17 insertions, 4 deletions
diff --git a/tests/t0501-about-render.sh b/tests/t0501-about-render.sh
index f870c0e..263c79b 100755
--- a/tests/t0501-about-render.sh
+++ b/tests/t0501-about-render.sh
@@ -13,7 +13,7 @@ CGIT_TEST_NO_CREATE_REPOS=YesPlease
. ./setup.sh
. "$TEST_OUTPUT_DIRECTORY/extensions/lib.sh"
-interpreters=$(ext_lua_interpreters 4)
+interpreters=$(ext_lua_interpreters 5)
test -z "$interpreters" &&
say 'no standalone lua on the path, unit checks skipped'
@@ -36,9 +36,12 @@ test_expect_success 'create a repository with a markdown readme' '
# The Title
A **bold** claim and a <script>alert(1)</script> attempt.
+
+ See the [roadmap](ROADMAP.md#plan).
EOF
git add README.md &&
- git commit -m "add readme"
+ git commit -m "add readme" &&
+ git branch next
)
'
@@ -48,7 +51,7 @@ test_expect_success 'point cgit at it through the about filter' '
cache-size=0
repo.url=md
repo.path=$PWD/repos/md/.git
- repo.readme=master:README.md
+ repo.readme=:README.md
repo.about-filter=lua:$EXTENSIONS_DIRECTORY/about-render.lua
EOF
'
@@ -68,7 +71,7 @@ fi
test_expect_success CGIT_LUA_LPEG 'the about page renders the markdown' '
cgit_url "md/about/" >tmp &&
- grep "<h1>The Title</h1>" tmp &&
+ grep "<h1 id=.the-title.>The Title</h1>" tmp &&
grep "<strong>bold</strong>" tmp
'
@@ -78,6 +81,16 @@ test_expect_success CGIT_LUA_LPEG 'readme markup reaches the page escaped' '
! grep "<script>alert(1)" tmp
'
+test_expect_success CGIT_LUA_LPEG 'a relative link leads into the tree' '
+ cgit_url "md/about/" >tmp &&
+ grep "<a href=./md/tree/ROADMAP.md#plan.>roadmap</a>" tmp
+'
+
+test_expect_success CGIT_LUA_LPEG 'the link stays on the branch shown' '
+ cgit_query "url=md/about/&h=next" >tmp &&
+ grep "<a href=./md/tree/ROADMAP.md?h=next#plan.>roadmap</a>" tmp
+'
+
test_expect_success CGIT_LUA_NOLPEG 'without lpeg the readme is served escaped' '
cgit_url "md/about/" >tmp &&
grep "<pre class=.plaintext.>" tmp &&