z_create_reply_13_filetest.gno
1.20 Kb · 43 lines
1// PKGPATH: gno.land/r/gnoland/boards2/v1/filetests/z_create_reply_13_filetest
2
3// A reply may now contain Markdown block structure (here a blockquote).
4// The write-time blacklist used to reject it; now the reply body renders
5// inside a <gno-foreign> sandbox, so its structure is contained and
6// cannot hijack realm chrome.
7package z_create_reply_13_filetest
8
9import (
10 "strings"
11 "testing"
12
13 "gno.land/p/gnoland/boards"
14
15 boards2 "gno.land/r/gnoland/boards2/v1"
16)
17
18const owner address = "g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh"
19
20var (
21 bid boards.ID
22 tid boards.ID
23)
24
25func init(cur realm) {
26 testing.SetRealm(testing.NewUserRealm(owner))
27 bid = boards2.CreateBoard(cross(cur), "test-board", false, false)
28 tid = boards2.CreateThread(cross(cur), bid, "Foo", "bar")
29}
30
31func main(cur realm) {
32 testing.SetRealm(testing.NewUserRealm(owner))
33
34 // Previously rejected ("headings, blockquotes ... not allowed").
35 boards2.CreateReply(cross(cur), bid, tid, 0, "> Markdown blockquote")
36
37 // The reply body is wrapped in a gno-foreign sandbox at render time.
38 content := boards2.Render("test-board/1")
39 println(strings.Contains(content, "Markdown blockquote") && strings.Contains(content, "<gno-foreign>"))
40}
41
42// Output:
43// true