codespan_test.gno
0.87 Kb · 22 lines
1package pairreg
2
3import (
4 "strings"
5 "testing"
6
7 "gno.land/p/nt/uassert/v0"
8)
9
10// The not-found branch echoes the visitor's URL path into a code span. Built by
11// hand, a backtick in the path closed the span early and everything after it
12// rendered as markdown on a gno.land page. md.InlineCode sizes the fence past
13// any backtick run in the content, so the payload must come back wrapped in a
14// DOUBLE fence, with the backtick intact inside it. Asserting on the payload
15// itself rather than on any double fence in the page: an earlier version of
16// this test passed on an unrelated span elsewhere in the output.
17func TestRenderPathCannotEscapeItsCodeSpan(t *testing.T) {
18 out := Render("/a`b")
19 fenced := strings.Contains(out, "``a`b``") || strings.Contains(out, "``/a`b``")
20 uassert.True(t, fenced,
21 "the fence did not outscan the caller's backtick, so the span closes early")
22}