diff options
author | Wim <wim@42.be> | 2022-08-13 16:14:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-13 16:14:26 +0200 |
commit | 6a3fc713978a0c1c9290a4afd08b47886b49b635 (patch) | |
tree | aa62cd85cf5671646c75ee38b3fc140ef7edcea8 /vendor/github.com/gomarkdown/markdown/html | |
parent | 3c4192ebf6a32e30cdd23a9644c2ceca72a006fa (diff) | |
download | matterbridge-msglm-6a3fc713978a0c1c9290a4afd08b47886b49b635.tar.gz matterbridge-msglm-6a3fc713978a0c1c9290a4afd08b47886b49b635.tar.bz2 matterbridge-msglm-6a3fc713978a0c1c9290a4afd08b47886b49b635.zip |
Update dependencies and go1.18 (#1873)
* Update dependencies and go1.18
* Exclude unnecessary linters and update build to go1.18
Diffstat (limited to 'vendor/github.com/gomarkdown/markdown/html')
-rw-r--r-- | vendor/github.com/gomarkdown/markdown/html/renderer.go | 36 |
1 files changed, 11 insertions, 25 deletions
diff --git a/vendor/github.com/gomarkdown/markdown/html/renderer.go b/vendor/github.com/gomarkdown/markdown/html/renderer.go index 42b39f30..875debe3 100644 --- a/vendor/github.com/gomarkdown/markdown/html/renderer.go +++ b/vendor/github.com/gomarkdown/markdown/html/renderer.go @@ -133,6 +133,9 @@ type Renderer struct { // if > 0, will strip html tags in Out and Outs DisableTags int + // TODO: documentation + IsSafeURLOverride func(url []byte) bool + sr *SPRenderer documentMatter ast.DocumentMatters // keep track of front/main/back matter. @@ -281,11 +284,16 @@ func isMailto(link []byte) bool { return bytes.HasPrefix(link, []byte("mailto:")) } -func needSkipLink(flags Flags, dest []byte) bool { +func needSkipLink(r *Renderer, dest []byte) bool { + flags := r.opts.Flags if flags&SkipLinks != 0 { return true } - return flags&Safelink != 0 && !isSafeLink(dest) && !isMailto(dest) + isSafeURL := r.IsSafeURLOverride + if isSafeURL == nil { + isSafeURL = valid.IsSafeURL + } + return flags&Safelink != 0 && !isSafeURL(dest) && !isMailto(dest) } func appendLanguageAttr(attrs []string, info []byte) []string { @@ -481,7 +489,7 @@ func (r *Renderer) linkExit(w io.Writer, link *ast.Link) { // Link writes ast.Link node func (r *Renderer) Link(w io.Writer, link *ast.Link, entering bool) { // mark it but don't link it if it is not a safe link: no smartypants - if needSkipLink(r.opts.Flags, link.Destination) { + if needSkipLink(r, link.Destination) { r.OutOneOf(w, entering, "<tt>", "</tt>") return } @@ -1226,28 +1234,6 @@ func isListItemTerm(node ast.Node) bool { return ok && data.ListFlags&ast.ListTypeTerm != 0 } -func isSafeLink(link []byte) bool { - for _, path := range valid.Paths { - if len(link) >= len(path) && bytes.Equal(link[:len(path)], path) { - if len(link) == len(path) { - return true - } else if isAlnum(link[len(path)]) { - return true - } - } - } - - for _, prefix := range valid.URIs { - // TODO: handle unicode here - // case-insensitive prefix test - if len(link) > len(prefix) && bytes.Equal(bytes.ToLower(link[:len(prefix)]), prefix) && isAlnum(link[len(prefix)]) { - return true - } - } - - return false -} - // TODO: move to internal package // Create a url-safe slug for fragments func slugify(in []byte) []byte { |