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

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

zz_escape_test.gno

0.95 Kb · 28 lines
 1package handles
 2
 3import (
 4	"strings"
 5	"testing"
 6
 7	"gno.land/p/nt/testutils/v0"
 8	"gno.land/p/nym-moultest123/md/v0"
 9	"gno.land/p/nt/uassert/v0"
10)
11
12// A bio is the caller's text: escaped on the handle page.
13func TestBioIsEscaped(cur realm, t *testing.T) {
14	testing.SetRealm(testing.NewUserRealm(testutils.TestAddress("escaper")))
15	Register(cross(cur), "escaper")
16	SetBio(cross(cur), "[claim](https://evil.example)")
17	page := Render("escaper")
18	uassert.False(t, strings.Contains(page, "[claim](https://evil.example)"), page)
19}
20
21// A path that names nothing is echoed back on the not-found page. It is the
22// visitor's text, so a backtick in it must not close a code span and let a
23// link through.
24func TestNotFoundPathIsEscaped(t *testing.T) {
25	out := Render("x` [claim](https://evil.example) `")
26	// Still there, but inside a span md.InlineCode widened past its backticks.
27	uassert.True(t, strings.Contains(out, md.InlineCode("x` [claim](https://evil.example) `")), out)
28}