diff options
Diffstat (limited to 'vendor/github.com/gomarkdown/markdown/parser')
-rw-r--r-- | vendor/github.com/gomarkdown/markdown/parser/inline.go | 35 | ||||
-rw-r--r-- | vendor/github.com/gomarkdown/markdown/parser/parser.go | 3 |
2 files changed, 8 insertions, 30 deletions
diff --git a/vendor/github.com/gomarkdown/markdown/parser/inline.go b/vendor/github.com/gomarkdown/markdown/parser/inline.go index ae7f244e..c16eddd8 100644 --- a/vendor/github.com/gomarkdown/markdown/parser/inline.go +++ b/vendor/github.com/gomarkdown/markdown/parser/inline.go @@ -899,7 +899,11 @@ func autoLink(p *Parser, data []byte, offset int) (int, ast.Node) { origData := data data = data[offset-rewind:] - if !isSafeLink(data) { + isSafeURL := p.IsSafeURLOverride + if isSafeURL == nil { + isSafeURL = valid.IsSafeURL + } + if !isSafeURL(data) { return 0, nil } @@ -995,35 +999,6 @@ func isEndOfLink(char byte) bool { return isSpace(char) || char == '<' } -func isSafeLink(link []byte) bool { - nLink := len(link) - for _, path := range valid.Paths { - nPath := len(path) - linkPrefix := link[:nPath] - if nLink >= nPath && bytes.Equal(linkPrefix, path) { - if nLink == nPath { - return true - } else if isAlnum(link[nPath]) { - return true - } - } - } - - for _, prefix := range valid.URIs { - // TODO: handle unicode here - // case-insensitive prefix test - nPrefix := len(prefix) - if nLink > nPrefix { - linkPrefix := bytes.ToLower(link[:nPrefix]) - if bytes.Equal(linkPrefix, prefix) && isAlnum(link[nPrefix]) { - return true - } - } - } - - return false -} - // return the length of the given tag, or 0 is it's not valid func tagLength(data []byte) (autolink autolinkType, end int) { var i, j int diff --git a/vendor/github.com/gomarkdown/markdown/parser/parser.go b/vendor/github.com/gomarkdown/markdown/parser/parser.go index eb63a911..19d1f70b 100644 --- a/vendor/github.com/gomarkdown/markdown/parser/parser.go +++ b/vendor/github.com/gomarkdown/markdown/parser/parser.go @@ -84,6 +84,9 @@ type Parser struct { // the bottom will be used to fill in the link details. ReferenceOverride ReferenceOverrideFunc + // TODO: documentation + IsSafeURLOverride func(url []byte) bool + Opts Options // after parsing, this is AST root of parsed markdown text |