From 6a3fc713978a0c1c9290a4afd08b47886b49b635 Mon Sep 17 00:00:00 2001
From: Wim <wim@42.be>
Date: Sat, 13 Aug 2022 16:14:26 +0200
Subject: Update dependencies and go1.18 (#1873)

* Update dependencies and go1.18

* Exclude unnecessary linters and update build to go1.18
---
 vendor/github.com/gomarkdown/markdown/README.md    | 24 ++++++------
 .../gomarkdown/markdown/html/renderer.go           | 36 ++++++-----------
 .../gomarkdown/markdown/internal/valid/valid.go    | 45 ++++++++++++++++++++++
 .../gomarkdown/markdown/parser/inline.go           | 35 +++--------------
 .../gomarkdown/markdown/parser/parser.go           |  3 ++
 5 files changed, 75 insertions(+), 68 deletions(-)

(limited to 'vendor/github.com/gomarkdown')

diff --git a/vendor/github.com/gomarkdown/markdown/README.md b/vendor/github.com/gomarkdown/markdown/README.md
index f84577f4..a85ce69c 100644
--- a/vendor/github.com/gomarkdown/markdown/README.md
+++ b/vendor/github.com/gomarkdown/markdown/README.md
@@ -2,9 +2,11 @@
 
 [![pkg.go.dev](https://pkg.go.dev/badge/github.com/gomarkdown/markdown)](https://pkg.go.dev/github.com/gomarkdown/markdown)
 
-Package `github.com/gomarkdown/markdown` is a very fast Go library for parsing [Markdown](https://daringfireball.net/projects/markdown/) documents and rendering them to HTML.
+Package `github.com/gomarkdown/markdown` is a Go library for parsing Markdown text and rendering as HTML.
 
-It's fast and supports common extensions.
+It's very fast and supports common extensions.
+
+Try code examples online: https://replit.com/@kjk1?path=folder/gomarkdown
 
 ## API Docs:
 
@@ -15,17 +17,7 @@ It's fast and supports common extensions.
 
 ## Users
 
-Some tools using this package:
-
-- https://github.com/MichaelMure/go-term-markdown : markdown renderer for the terminal
-- https://github.com/artyom/mdserver : web server that serves markdown files
-- https://github.com/rsdoiel/mkpage : content management system generating static websites
-- https://github.com/cugu/dashboard : creates a badge dashboard from a yaml file
-- https://github.com/ieyasu/go-bwiki : simple wiki
-- https://github.com/romanyx/mdopen : view markdown files in the default browser
-- https://github.com/ystyle/sqlmanager : a library for manager sql with markdown like beetsql
-- https://gitlab.com/kendellfab/fazer : library for making templates
-- https://github.com/blmayer/tasker : a simple task list web app
+Some tools using this package: https://pkg.go.dev/github.com/gomarkdown/markdown?tab=importedby
 
 ## Usage
 
@@ -36,6 +28,8 @@ md := []byte("## markdown document")
 output := markdown.ToHTML(md, nil, nil)
 ```
 
+Try it online: https://replit.com/@kjk1/gomarkdown-basic
+
 ## Customizing markdown parser
 
 Markdown format is loosely specified and there are multiple extensions invented after original specification was created.
@@ -57,6 +51,8 @@ md := []byte("markdown text")
 html := markdown.ToHTML(md, parser, nil)
 ```
 
+Try it online: https://replit.com/@kjk1/gomarkdown-customized-html-renderer
+
 ## Customizing HTML renderer
 
 Similarly, HTML renderer can be configured with different [options](https://pkg.go.dev/github.com/gomarkdown/markdown/html#RendererOptions)
@@ -77,6 +73,8 @@ md := []byte("markdown text")
 html := markdown.ToHTML(md, nil, renderer)
 ```
 
+Try it online: https://replit.com/@kjk1/gomarkdown-customized-html-renderer
+
 HTML renderer also supports reusing most of the logic and overriding rendering of only specific nodes.
 
 You can provide [RenderNodeFunc](https://pkg.go.dev/github.com/gomarkdown/markdown/html#RenderNodeFunc) in [RendererOptions](https://pkg.go.dev/github.com/gomarkdown/markdown/html#RendererOptions).
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 {
diff --git a/vendor/github.com/gomarkdown/markdown/internal/valid/valid.go b/vendor/github.com/gomarkdown/markdown/internal/valid/valid.go
index b9a761eb..9b3de3ec 100644
--- a/vendor/github.com/gomarkdown/markdown/internal/valid/valid.go
+++ b/vendor/github.com/gomarkdown/markdown/internal/valid/valid.go
@@ -1,5 +1,9 @@
 package valid
 
+import (
+	"bytes"
+)
+
 var URIs = [][]byte{
 	[]byte("http://"),
 	[]byte("https://"),
@@ -12,3 +16,44 @@ var Paths = [][]byte{
 	[]byte("./"),
 	[]byte("../"),
 }
+
+// TODO: documentation
+func IsSafeURL(url []byte) bool {
+	nLink := len(url)
+	for _, path := range Paths {
+		nPath := len(path)
+		linkPrefix := url[:nPath]
+		if nLink >= nPath && bytes.Equal(linkPrefix, path) {
+			if nLink == nPath {
+				return true
+			} else if isAlnum(url[nPath]) {
+				return true
+			}
+		}
+	}
+
+	for _, prefix := range URIs {
+		// TODO: handle unicode here
+		// case-insensitive prefix test
+		nPrefix := len(prefix)
+		if nLink > nPrefix {
+			linkPrefix := bytes.ToLower(url[:nPrefix])
+			if bytes.Equal(linkPrefix, prefix) && isAlnum(url[nPrefix]) {
+				return true
+			}
+		}
+	}
+
+	return false
+}
+
+// isAlnum returns true if c is a digit or letter
+// TODO: check when this is looking for ASCII alnum and when it should use unicode
+func isAlnum(c byte) bool {
+	return (c >= '0' && c <= '9') || isLetter(c)
+}
+
+// isLetter returns true if c is ascii letter
+func isLetter(c byte) bool {
+	return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
+}
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
-- 
cgit v1.2.3