4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-07-11 21:16:27 +00:00

Update dependencies and go1.18 (#1873)

* Update dependencies and go1.18

* Exclude unnecessary linters and update build to go1.18
This commit is contained in:
Wim
2022-08-13 16:14:26 +02:00
committed by GitHub
parent 3c4192ebf6
commit 6a3fc71397
396 changed files with 350176 additions and 309792 deletions

View File

@ -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

View File

@ -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