Skip to content

Commit

Permalink
Tests for links when using HTML_SAFELINK
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoxall committed Dec 19, 2013
1 parent 59358ad commit 607ec21
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions inline_test.go
Expand Up @@ -32,6 +32,10 @@ func doTestsInline(t *testing.T, tests []string) {
doTestsInlineParam(t, tests, 0, 0)
}

func doSafeTestsInline(t *testing.T, tests []string) {
doTestsInlineParam(t, tests, 0, HTML_SAFELINK)
}

func doTestsInlineParam(t *testing.T, tests []string, extensions, htmlFlags int) {
// catch and report panics
var candidate string
Expand Down Expand Up @@ -417,6 +421,30 @@ func TestInlineLink(t *testing.T) {
doTestsInline(t, tests)
}

func TestSafeInlineLink(t *testing.T) {
var tests = []string{
"[foo](/bar/)\n",
"<p><a href=\"/bar/\">foo</a></p>\n",

"[foo](http://bar/)\n",
"<p><a href=\"http://bar/\">foo</a></p>\n",

"[foo](https://bar/)\n",
"<p><a href=\"https://bar/\">foo</a></p>\n",

"[foo](ftp://bar/)\n",
"<p><a href=\"ftp://bar/\">foo</a></p>\n",

"[foo](mailto://bar/)\n",
"<p><a href=\"mailto://bar/\">foo</a></p>\n",

// Not considered safe
"[foo](baz://bar/)\n",
"<p><tt>foo</tt></p>\n",
}
doSafeTestsInline(t, tests)
}

func TestReferenceLink(t *testing.T) {
var tests = []string{
"[link][ref]\n",
Expand Down

0 comments on commit 607ec21

Please sign in to comment.