Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

z_create_reply_13_filetest.gno

1.20 Kb · 43 lines
 1// PKGPATH: gno.land/r/gnoland/boards2/v0/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/v0"
14
15	boards2 "gno.land/r/gnoland/boards2/v0"
16)
17
18const owner address = "g1skl80cuz8zq3lul9pgz5pc35l2pfzgxgfpsqkx"
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