summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/gomarkdown/markdown/parser
diff options
context:
space:
mode:
authorWim <wim@42.be>2022-08-13 16:14:26 +0200
committerGitHub <noreply@github.com>2022-08-13 16:14:26 +0200
commit6a3fc713978a0c1c9290a4afd08b47886b49b635 (patch)
treeaa62cd85cf5671646c75ee38b3fc140ef7edcea8 /vendor/github.com/gomarkdown/markdown/parser
parent3c4192ebf6a32e30cdd23a9644c2ceca72a006fa (diff)
downloadmatterbridge-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/parser')
-rw-r--r--vendor/github.com/gomarkdown/markdown/parser/inline.go35
-rw-r--r--vendor/github.com/gomarkdown/markdown/parser/parser.go3
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