28 lines
677 B
Go
28 lines
677 B
Go
package markdown
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/andrew/superbrain/internal/db"
|
|
)
|
|
|
|
// Review L-11: link destinations are wrapped and escaped so parentheses or
|
|
// angle brackets in a bookmark URL cannot terminate or extend the link.
|
|
func TestPageDocumentEscapesLinkDestinations(t *testing.T) {
|
|
out := PageDocument(db.Object{
|
|
"title": "Links",
|
|
"content": "",
|
|
"bookmarks": []any{
|
|
map[string]any{"bookmark": map[string]any{
|
|
"title": "Odd",
|
|
"url": "https://example.com/a(b)?x=<y>",
|
|
}},
|
|
},
|
|
})
|
|
want := "[Odd](<https://example.com/a(b)?x=%3Cy%3E>)"
|
|
if !strings.Contains(out, want) {
|
|
t.Fatalf("link destination not escaped:\n%s", out)
|
|
}
|
|
}
|