[chore]: Bump github.com/yuin/goldmark from 1.7.8 to 1.7.10 (#4037)

Bumps [github.com/yuin/goldmark](https://github.com/yuin/goldmark) from 1.7.8 to 1.7.10.
- [Release notes](https://github.com/yuin/goldmark/releases)
- [Commits](https://github.com/yuin/goldmark/compare/v1.7.8...v1.7.10)

---
updated-dependencies:
- dependency-name: github.com/yuin/goldmark
  dependency-version: 1.7.10
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
dependabot[bot]
2025-04-22 12:32:39 +02:00
committed by GitHub
parent 075cae3d55
commit f170bbcd49
14 changed files with 201 additions and 3832 deletions

2
go.mod
View File

@ -73,7 +73,7 @@ require (
github.com/uptrace/bun/dialect/sqlitedialect v1.2.11 github.com/uptrace/bun/dialect/sqlitedialect v1.2.11
github.com/uptrace/bun/extra/bunotel v1.2.11 github.com/uptrace/bun/extra/bunotel v1.2.11
github.com/wagslane/go-password-validator v0.3.0 github.com/wagslane/go-password-validator v0.3.0
github.com/yuin/goldmark v1.7.8 github.com/yuin/goldmark v1.7.10
go.opentelemetry.io/otel v1.35.0 go.opentelemetry.io/otel v1.35.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.35.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.35.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.34.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.34.0

4
go.sum generated
View File

@ -487,8 +487,8 @@ github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FB
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M= github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M=
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yuin/goldmark v1.7.8 h1:iERMLn0/QJeHFhxSt3p6PeN9mGnvIKSpG9YYorDMnic= github.com/yuin/goldmark v1.7.10 h1:S+LrtBjRmqMac2UdtB6yyCEJm+UILZ2fefI4p7o0QpI=
github.com/yuin/goldmark v1.7.8/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= github.com/yuin/goldmark v1.7.10/go.mod h1:ip/1k0VRfGynBgxOz0yCqHrbZXhcjxyuS66Brc7iBKg=
gitlab.com/NyaaaWhatsUpDoc/sqlite v1.37.0-concurrency-workaround h1:QbfrBqNKgAFSSK89fYf547vxDQuz8p6iJUzzAMrusNk= gitlab.com/NyaaaWhatsUpDoc/sqlite v1.37.0-concurrency-workaround h1:QbfrBqNKgAFSSK89fYf547vxDQuz8p6iJUzzAMrusNk=
gitlab.com/NyaaaWhatsUpDoc/sqlite v1.37.0-concurrency-workaround/go.mod h1:5YiWv+YviqGMuGw4V+PNplcyaJ5v+vQd7TQOgkACoJM= gitlab.com/NyaaaWhatsUpDoc/sqlite v1.37.0-concurrency-workaround/go.mod h1:5YiWv+YviqGMuGw4V+PNplcyaJ5v+vQd7TQOgkACoJM=
go.mongodb.org/mongo-driver v1.14.0 h1:P98w8egYRjYe3XDjxhYJagTokP/H6HzlsnojRgZRd80= go.mongodb.org/mongo-driver v1.14.0 h1:P98w8egYRjYe3XDjxhYJagTokP/H6HzlsnojRgZRd80=

View File

@ -1,6 +1,3 @@
run:
deadline: 10m
issues: issues:
exclude-use-default: false exclude-use-default: false
exclude-rules: exclude-rules:

View File

@ -1,4 +1,4 @@
.PHONY: test fuzz lint .PHONY: test fuzz lint gen
lint: lint:
golangci-lint run -c .golangci.yml ./... golangci-lint run -c .golangci.yml ./...
@ -10,4 +10,7 @@ cov: test
go tool cover -html=profile.out go tool cover -html=profile.out
fuzz: fuzz:
cd ./fuzz && go test -fuzz=Fuzz cd ./fuzz && go test -fuzz=FuzzDefault
gen:
go generate ./...

View File

@ -2,7 +2,7 @@ goldmark
========================================== ==========================================
[![https://pkg.go.dev/github.com/yuin/goldmark](https://pkg.go.dev/badge/github.com/yuin/goldmark.svg)](https://pkg.go.dev/github.com/yuin/goldmark) [![https://pkg.go.dev/github.com/yuin/goldmark](https://pkg.go.dev/badge/github.com/yuin/goldmark.svg)](https://pkg.go.dev/github.com/yuin/goldmark)
[![https://github.com/yuin/goldmark/actions?query=workflow:test](https://github.com/yuin/goldmark/workflows/test/badge.svg?branch=master&event=push)](https://github.com/yuin/goldmark/actions?query=workflow:test) [![https://github.com/yuin/goldmark/actions?query=workflow:test](https://github.com/yuin/goldmark/actions/workflows/test.yaml/badge.svg?branch=master&event=push)](https://github.com/yuin/goldmark/actions?query=workflow:test)
[![https://coveralls.io/github/yuin/goldmark](https://coveralls.io/repos/github/yuin/goldmark/badge.svg?branch=master)](https://coveralls.io/github/yuin/goldmark) [![https://coveralls.io/github/yuin/goldmark](https://coveralls.io/repos/github/yuin/goldmark/badge.svg?branch=master)](https://coveralls.io/github/yuin/goldmark)
[![https://goreportcard.com/report/github.com/yuin/goldmark](https://goreportcard.com/badge/github.com/yuin/goldmark)](https://goreportcard.com/report/github.com/yuin/goldmark) [![https://goreportcard.com/report/github.com/yuin/goldmark](https://goreportcard.com/badge/github.com/yuin/goldmark)](https://goreportcard.com/report/github.com/yuin/goldmark)
@ -493,7 +493,7 @@ Extensions
- [goldmark-d2](https://github.com/FurqanSoftware/goldmark-d2): Adds support for [D2](https://d2lang.com/) diagrams. - [goldmark-d2](https://github.com/FurqanSoftware/goldmark-d2): Adds support for [D2](https://d2lang.com/) diagrams.
- [goldmark-katex](https://github.com/FurqanSoftware/goldmark-katex): Adds support for [KaTeX](https://katex.org/) math and equations. - [goldmark-katex](https://github.com/FurqanSoftware/goldmark-katex): Adds support for [KaTeX](https://katex.org/) math and equations.
- [goldmark-img64](https://github.com/tenkoh/goldmark-img64): Adds support for embedding images into the document as DataURL (base64 encoded). - [goldmark-img64](https://github.com/tenkoh/goldmark-img64): Adds support for embedding images into the document as DataURL (base64 encoded).
- [goldmark-enclave](https://github.com/quail-ink/goldmark-enclave): Adds support for embedding youtube/bilibili video, X's [oembed tweet](https://publish.twitter.com/), [tradingview](https://www.tradingview.com/widget/)'s chart, [quail](https://quail.ink)'s widget into the document. - [goldmark-enclave](https://github.com/quailyquaily/goldmark-enclave): Adds support for embedding youtube/bilibili video, X's [oembed X](https://publish.x.com/), [tradingview chart](https://www.tradingview.com/widget/)'s chart, [quaily widget](https://quaily.com), [spotify embeds](https://developer.spotify.com/documentation/embeds), [dify embed](https://dify.ai/) and html audio into the document.
- [goldmark-wiki-table](https://github.com/movsb/goldmark-wiki-table): Adds support for embedding Wiki Tables. - [goldmark-wiki-table](https://github.com/movsb/goldmark-wiki-table): Adds support for embedding Wiki Tables.
- [goldmark-tgmd](https://github.com/Mad-Pixels/goldmark-tgmd): A Telegram markdown renderer that can be passed to `goldmark.WithRenderer()`. - [goldmark-tgmd](https://github.com/Mad-Pixels/goldmark-tgmd): A Telegram markdown renderer that can be passed to `goldmark.WithRenderer()`.

View File

@ -358,17 +358,17 @@ func (r *TableHTMLRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegistere
} }
// TableAttributeFilter defines attribute names which table elements can have. // TableAttributeFilter defines attribute names which table elements can have.
var TableAttributeFilter = html.GlobalAttributeFilter.Extend( //
[]byte("align"), // [Deprecated] // - align: Deprecated
[]byte("bgcolor"), // [Deprecated] // - bgcolor: Deprecated
[]byte("border"), // [Deprecated] // - border: Deprecated
[]byte("cellpadding"), // [Deprecated] // - cellpadding: Deprecated
[]byte("cellspacing"), // [Deprecated] // - cellspacing: Deprecated
[]byte("frame"), // [Deprecated] // - frame: Deprecated
[]byte("rules"), // [Deprecated] // - rules: Deprecated
[]byte("summary"), // [Deprecated] // - summary: Deprecated
[]byte("width"), // [Deprecated] // - width: Deprecated.
) var TableAttributeFilter = html.GlobalAttributeFilter.ExtendString(`align,bgcolor,border,cellpadding,cellspacing,frame,rules,summary,width`) // nolint: lll
func (r *TableHTMLRenderer) renderTable( func (r *TableHTMLRenderer) renderTable(
w util.BufWriter, source []byte, n gast.Node, entering bool) (gast.WalkStatus, error) { w util.BufWriter, source []byte, n gast.Node, entering bool) (gast.WalkStatus, error) {
@ -385,13 +385,13 @@ func (r *TableHTMLRenderer) renderTable(
} }
// TableHeaderAttributeFilter defines attribute names which <thead> elements can have. // TableHeaderAttributeFilter defines attribute names which <thead> elements can have.
var TableHeaderAttributeFilter = html.GlobalAttributeFilter.Extend( //
[]byte("align"), // [Deprecated since HTML4] [Obsolete since HTML5] // - align: Deprecated since HTML4, Obsolete since HTML5
[]byte("bgcolor"), // [Not Standardized] // - bgcolor: Not Standardized
[]byte("char"), // [Deprecated since HTML4] [Obsolete since HTML5] // - char: Deprecated since HTML4, Obsolete since HTML5
[]byte("charoff"), // [Deprecated since HTML4] [Obsolete since HTML5] // - charoff: Deprecated since HTML4, Obsolete since HTML5
[]byte("valign"), // [Deprecated since HTML4] [Obsolete since HTML5] // - valign: Deprecated since HTML4, Obsolete since HTML5.
) var TableHeaderAttributeFilter = html.GlobalAttributeFilter.ExtendString(`align,bgcolor,char,charoff,valign`)
func (r *TableHTMLRenderer) renderTableHeader( func (r *TableHTMLRenderer) renderTableHeader(
w util.BufWriter, source []byte, n gast.Node, entering bool) (gast.WalkStatus, error) { w util.BufWriter, source []byte, n gast.Node, entering bool) (gast.WalkStatus, error) {
@ -413,13 +413,13 @@ func (r *TableHTMLRenderer) renderTableHeader(
} }
// TableRowAttributeFilter defines attribute names which <tr> elements can have. // TableRowAttributeFilter defines attribute names which <tr> elements can have.
var TableRowAttributeFilter = html.GlobalAttributeFilter.Extend( //
[]byte("align"), // [Obsolete since HTML5] // - align: Obsolete since HTML5
[]byte("bgcolor"), // [Obsolete since HTML5] // - bgcolor: Obsolete since HTML5
[]byte("char"), // [Obsolete since HTML5] // - char: Obsolete since HTML5
[]byte("charoff"), // [Obsolete since HTML5] // - charoff: Obsolete since HTML5
[]byte("valign"), // [Obsolete since HTML5] // - valign: Obsolete since HTML5.
) var TableRowAttributeFilter = html.GlobalAttributeFilter.ExtendString(`align,bgcolor,char,charoff,valign`)
func (r *TableHTMLRenderer) renderTableRow( func (r *TableHTMLRenderer) renderTableRow(
w util.BufWriter, source []byte, n gast.Node, entering bool) (gast.WalkStatus, error) { w util.BufWriter, source []byte, n gast.Node, entering bool) (gast.WalkStatus, error) {
@ -439,50 +439,41 @@ func (r *TableHTMLRenderer) renderTableRow(
} }
// TableThCellAttributeFilter defines attribute names which table <th> cells can have. // TableThCellAttributeFilter defines attribute names which table <th> cells can have.
var TableThCellAttributeFilter = html.GlobalAttributeFilter.Extend( //
[]byte("abbr"), // [OK] Contains a short abbreviated description of the cell's content [NOT OK in <td>] // - abbr: [OK] Contains a short abbreviated description of the cell's content [NOT OK in <td>]
// - align: Obsolete since HTML5
[]byte("align"), // [Obsolete since HTML5] // - axis: Obsolete since HTML5
[]byte("axis"), // [Obsolete since HTML5] // - bgcolor: Not Standardized
[]byte("bgcolor"), // [Not Standardized] // - char: Obsolete since HTML5
[]byte("char"), // [Obsolete since HTML5] // - charoff: Obsolete since HTML5
[]byte("charoff"), // [Obsolete since HTML5] // - colspan: [OK] Number of columns that the cell is to span
// - headers: [OK] This attribute contains a list of space-separated strings,
[]byte("colspan"), // [OK] Number of columns that the cell is to span // each corresponding to the id attribute of the <th> elements that apply to this element
[]byte("headers"), // [OK] This attribute contains a list of space-separated // - height: Deprecated since HTML4. Obsolete since HTML5
// strings, each corresponding to the id attribute of the <th> elements that apply to this element // - rowspan: [OK] Number of rows that the cell is to span
// - scope: [OK] This enumerated attribute defines the cells that the header
[]byte("height"), // [Deprecated since HTML4] [Obsolete since HTML5] // (defined in the <th>) element relates to [NOT OK in <td>]
// - valign: Obsolete since HTML5
[]byte("rowspan"), // [OK] Number of rows that the cell is to span // - width: Deprecated since HTML4. Obsolete since HTML5.
[]byte("scope"), // [OK] This enumerated attribute defines the cells that var TableThCellAttributeFilter = html.GlobalAttributeFilter.ExtendString(`abbr,align,axis,bgcolor,char,charoff,colspan,headers,height,rowspan,scope,valign,width`) // nolint:lll
// the header (defined in the <th>) element relates to [NOT OK in <td>]
[]byte("valign"), // [Obsolete since HTML5]
[]byte("width"), // [Deprecated since HTML4] [Obsolete since HTML5]
)
// TableTdCellAttributeFilter defines attribute names which table <td> cells can have. // TableTdCellAttributeFilter defines attribute names which table <td> cells can have.
var TableTdCellAttributeFilter = html.GlobalAttributeFilter.Extend( //
[]byte("abbr"), // [Obsolete since HTML5] [OK in <th>] // - abbr: Obsolete since HTML5. [OK in <th>]
[]byte("align"), // [Obsolete since HTML5] // - align: Obsolete since HTML5
[]byte("axis"), // [Obsolete since HTML5] // - axis: Obsolete since HTML5
[]byte("bgcolor"), // [Not Standardized] // - bgcolor: Not Standardized
[]byte("char"), // [Obsolete since HTML5] // - char: Obsolete since HTML5
[]byte("charoff"), // [Obsolete since HTML5] // - charoff: Obsolete since HTML5
// - colspan: [OK] Number of columns that the cell is to span
[]byte("colspan"), // [OK] Number of columns that the cell is to span // - headers: [OK] This attribute contains a list of space-separated strings, each corresponding
[]byte("headers"), // [OK] This attribute contains a list of space-separated // to the id attribute of the <th> elements that apply to this element
// strings, each corresponding to the id attribute of the <th> elements that apply to this element // - height: Deprecated since HTML4. Obsolete since HTML5
// - rowspan: [OK] Number of rows that the cell is to span
[]byte("height"), // [Deprecated since HTML4] [Obsolete since HTML5] // - scope: Obsolete since HTML5. [OK in <th>]
// - valign: Obsolete since HTML5
[]byte("rowspan"), // [OK] Number of rows that the cell is to span // - width: Deprecated since HTML4. Obsolete since HTML5.
var TableTdCellAttributeFilter = html.GlobalAttributeFilter.ExtendString(`abbr,align,axis,bgcolor,char,charoff,colspan,headers,height,rowspan,scope,valign,width`) // nolint: lll
[]byte("scope"), // [Obsolete since HTML5] [OK in <th>]
[]byte("valign"), // [Obsolete since HTML5]
[]byte("width"), // [Deprecated since HTML4] [Obsolete since HTML5]
)
func (r *TableHTMLRenderer) renderTableCell( func (r *TableHTMLRenderer) renderTableCell(
w util.BufWriter, source []byte, node gast.Node, entering bool) (gast.WalkStatus, error) { w util.BufWriter, source []byte, node gast.Node, entering bool) (gast.WalkStatus, error) {

View File

@ -111,7 +111,7 @@ func NewDelimiter(canOpen, canClose bool, length int, char byte, processor Delim
} }
// ScanDelimiter scans a delimiter by given DelimiterProcessor. // ScanDelimiter scans a delimiter by given DelimiterProcessor.
func ScanDelimiter(line []byte, before rune, min int, processor DelimiterProcessor) *Delimiter { func ScanDelimiter(line []byte, before rune, minimum int, processor DelimiterProcessor) *Delimiter {
i := 0 i := 0
c := line[i] c := line[i]
j := i j := i
@ -120,7 +120,7 @@ func ScanDelimiter(line []byte, before rune, min int, processor DelimiterProcess
} }
for ; j < len(line) && c == line[j]; j++ { for ; j < len(line) && c == line[j]; j++ {
} }
if (j - i) >= min { if (j - i) >= minimum {
after := rune(' ') after := rune(' ')
if j != len(line) { if j != len(line) {
after = util.ToRune(line, j) after = util.ToRune(line, j)

View File

@ -295,35 +295,7 @@ func (r *Renderer) writeLines(w util.BufWriter, source []byte, n ast.Node) {
} }
// GlobalAttributeFilter defines attribute names which any elements can have. // GlobalAttributeFilter defines attribute names which any elements can have.
var GlobalAttributeFilter = util.NewBytesFilter( var GlobalAttributeFilter = util.NewBytesFilterString(`accesskey,autocapitalize,autofocus,class,contenteditable,dir,draggable,enterkeyhint,hidden,id,inert,inputmode,is,itemid,itemprop,itemref,itemscope,itemtype,lang,part,role,slot,spellcheck,style,tabindex,title,translate`) // nolint:lll
[]byte("accesskey"),
[]byte("autocapitalize"),
[]byte("autofocus"),
[]byte("class"),
[]byte("contenteditable"),
[]byte("dir"),
[]byte("draggable"),
[]byte("enterkeyhint"),
[]byte("hidden"),
[]byte("id"),
[]byte("inert"),
[]byte("inputmode"),
[]byte("is"),
[]byte("itemid"),
[]byte("itemprop"),
[]byte("itemref"),
[]byte("itemscope"),
[]byte("itemtype"),
[]byte("lang"),
[]byte("part"),
[]byte("role"),
[]byte("slot"),
[]byte("spellcheck"),
[]byte("style"),
[]byte("tabindex"),
[]byte("title"),
[]byte("translate"),
)
func (r *Renderer) renderDocument( func (r *Renderer) renderDocument(
w util.BufWriter, source []byte, node ast.Node, entering bool) (ast.WalkStatus, error) { w util.BufWriter, source []byte, node ast.Node, entering bool) (ast.WalkStatus, error) {
@ -353,9 +325,7 @@ func (r *Renderer) renderHeading(
} }
// BlockquoteAttributeFilter defines attribute names which blockquote elements can have. // BlockquoteAttributeFilter defines attribute names which blockquote elements can have.
var BlockquoteAttributeFilter = GlobalAttributeFilter.Extend( var BlockquoteAttributeFilter = GlobalAttributeFilter.ExtendString(`cite`)
[]byte("cite"),
)
func (r *Renderer) renderBlockquote( func (r *Renderer) renderBlockquote(
w util.BufWriter, source []byte, n ast.Node, entering bool) (ast.WalkStatus, error) { w util.BufWriter, source []byte, n ast.Node, entering bool) (ast.WalkStatus, error) {
@ -429,11 +399,7 @@ func (r *Renderer) renderHTMLBlock(
} }
// ListAttributeFilter defines attribute names which list elements can have. // ListAttributeFilter defines attribute names which list elements can have.
var ListAttributeFilter = GlobalAttributeFilter.Extend( var ListAttributeFilter = GlobalAttributeFilter.ExtendString(`start,reversed,type`)
[]byte("start"),
[]byte("reversed"),
[]byte("type"),
)
func (r *Renderer) renderList(w util.BufWriter, source []byte, node ast.Node, entering bool) (ast.WalkStatus, error) { func (r *Renderer) renderList(w util.BufWriter, source []byte, node ast.Node, entering bool) (ast.WalkStatus, error) {
n := node.(*ast.List) n := node.(*ast.List)
@ -460,9 +426,7 @@ func (r *Renderer) renderList(w util.BufWriter, source []byte, node ast.Node, en
} }
// ListItemAttributeFilter defines attribute names which list item elements can have. // ListItemAttributeFilter defines attribute names which list item elements can have.
var ListItemAttributeFilter = GlobalAttributeFilter.Extend( var ListItemAttributeFilter = GlobalAttributeFilter.ExtendString(`value`)
[]byte("value"),
)
func (r *Renderer) renderListItem(w util.BufWriter, source []byte, n ast.Node, entering bool) (ast.WalkStatus, error) { func (r *Renderer) renderListItem(w util.BufWriter, source []byte, n ast.Node, entering bool) (ast.WalkStatus, error) {
if entering { if entering {
@ -513,13 +477,7 @@ func (r *Renderer) renderTextBlock(w util.BufWriter, source []byte, n ast.Node,
} }
// ThematicAttributeFilter defines attribute names which hr elements can have. // ThematicAttributeFilter defines attribute names which hr elements can have.
var ThematicAttributeFilter = GlobalAttributeFilter.Extend( var ThematicAttributeFilter = GlobalAttributeFilter.ExtendString(`align,color,noshade,size,width`)
[]byte("align"), // [Deprecated]
[]byte("color"), // [Not Standardized]
[]byte("noshade"), // [Deprecated]
[]byte("size"), // [Deprecated]
[]byte("width"), // [Deprecated]
)
func (r *Renderer) renderThematicBreak( func (r *Renderer) renderThematicBreak(
w util.BufWriter, source []byte, n ast.Node, entering bool) (ast.WalkStatus, error) { w util.BufWriter, source []byte, n ast.Node, entering bool) (ast.WalkStatus, error) {
@ -539,17 +497,7 @@ func (r *Renderer) renderThematicBreak(
} }
// LinkAttributeFilter defines attribute names which link elements can have. // LinkAttributeFilter defines attribute names which link elements can have.
var LinkAttributeFilter = GlobalAttributeFilter.Extend( var LinkAttributeFilter = GlobalAttributeFilter.ExtendString(`download,hreflang,media,ping,referrerpolicy,rel,shape,target`) // nolint:lll
[]byte("download"),
// []byte("href"),
[]byte("hreflang"),
[]byte("media"),
[]byte("ping"),
[]byte("referrerpolicy"),
[]byte("rel"),
[]byte("shape"),
[]byte("target"),
)
func (r *Renderer) renderAutoLink( func (r *Renderer) renderAutoLink(
w util.BufWriter, source []byte, node ast.Node, entering bool) (ast.WalkStatus, error) { w util.BufWriter, source []byte, node ast.Node, entering bool) (ast.WalkStatus, error) {
@ -653,22 +601,7 @@ func (r *Renderer) renderLink(w util.BufWriter, source []byte, node ast.Node, en
} }
// ImageAttributeFilter defines attribute names which image elements can have. // ImageAttributeFilter defines attribute names which image elements can have.
var ImageAttributeFilter = GlobalAttributeFilter.Extend( var ImageAttributeFilter = GlobalAttributeFilter.ExtendString(`align,border,crossorigin,decoding,height,importance,intrinsicsize,ismap,loading,referrerpolicy,sizes,srcset,usemap,width`) // nolint: lll
[]byte("align"),
[]byte("border"),
[]byte("crossorigin"),
[]byte("decoding"),
[]byte("height"),
[]byte("importance"),
[]byte("intrinsicsize"),
[]byte("ismap"),
[]byte("loading"),
[]byte("referrerpolicy"),
[]byte("sizes"),
[]byte("srcset"),
[]byte("usemap"),
[]byte("width"),
)
func (r *Renderer) renderImage(w util.BufWriter, source []byte, node ast.Node, entering bool) (ast.WalkStatus, error) { func (r *Renderer) renderImage(w util.BufWriter, source []byte, node ast.Node, entering bool) (ast.WalkStatus, error) {
if !entering { if !entering {

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -528,12 +528,21 @@ func ToLinkReference(v []byte) string {
return string(ReplaceSpaces(v, ' ')) return string(ReplaceSpaces(v, ' '))
} }
var htmlEscapeTable = [256][]byte{nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, []byte("&quot;"), nil, nil, nil, []byte("&amp;"), nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, []byte("&lt;"), nil, []byte("&gt;"), nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil} //nolint:golint,lll var htmlQuote = []byte("&quot;")
var htmlAmp = []byte("&amp;")
var htmlLess = []byte("&lt;")
var htmlGreater = []byte("&gt;")
var htmlEscapeTable = [256]*[]byte{nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &htmlQuote, nil, nil, nil, &htmlAmp, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, &htmlLess, nil, &htmlGreater, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil} //nolint:golint,lll
// EscapeHTMLByte returns HTML escaped bytes if the given byte should be escaped, // EscapeHTMLByte returns HTML escaped bytes if the given byte should be escaped,
// otherwise nil. // otherwise nil.
func EscapeHTMLByte(b byte) []byte { func EscapeHTMLByte(b byte) []byte {
return htmlEscapeTable[b] v := htmlEscapeTable[b]
if v != nil {
return *v
}
return nil
} }
// EscapeHTML escapes characters that should be escaped in HTML text. // EscapeHTML escapes characters that should be escaped in HTML text.
@ -545,7 +554,7 @@ func EscapeHTML(v []byte) []byte {
escaped := htmlEscapeTable[c] escaped := htmlEscapeTable[c]
if escaped != nil { if escaped != nil {
cob.Write(v[n:i]) cob.Write(v[n:i])
cob.Write(escaped) cob.Write(*escaped)
n = i + 1 n = i + 1
} }
} }
@ -911,6 +920,10 @@ type BytesFilter interface {
// Extend copies this filter and adds given bytes to new filter. // Extend copies this filter and adds given bytes to new filter.
Extend(...[]byte) BytesFilter Extend(...[]byte) BytesFilter
// ExtendString copies this filter and adds given bytes to new filter.
// Given string must be separated by a comma.
ExtendString(string) BytesFilter
} }
type bytesFilter struct { type bytesFilter struct {
@ -931,6 +944,27 @@ func NewBytesFilter(elements ...[]byte) BytesFilter {
return s return s
} }
// NewBytesFilterString returns a new BytesFilter.
// Given string must be separated by a comma.
func NewBytesFilterString(elements string) BytesFilter {
s := &bytesFilter{
threshold: 3,
slots: make([][][]byte, 64),
}
start := 0
for i := 0; i < len(elements); i++ {
if elements[i] == ',' {
s.Add(StringToReadOnlyBytes(elements[start:i]))
start = i + 1
}
}
if start < len(elements) {
s.Add(StringToReadOnlyBytes(elements[start:]))
}
return s
}
func (s *bytesFilter) Add(b []byte) { func (s *bytesFilter) Add(b []byte) {
l := len(b) l := len(b)
m := s.threshold m := s.threshold
@ -963,6 +997,28 @@ func (s *bytesFilter) Extend(bs ...[]byte) BytesFilter {
return newFilter return newFilter
} }
func (s *bytesFilter) ExtendString(elements string) BytesFilter {
newFilter := NewBytesFilter().(*bytesFilter)
newFilter.chars = s.chars
newFilter.threshold = s.threshold
for k, v := range s.slots {
newSlot := make([][]byte, len(v))
copy(newSlot, v)
newFilter.slots[k] = v
}
start := 0
for i := 0; i < len(elements); i++ {
if elements[i] == ',' {
newFilter.Add(StringToReadOnlyBytes(elements[start:i]))
start = i + 1
}
}
if start < len(elements) {
newFilter.Add(StringToReadOnlyBytes(elements[start:]))
}
return newFilter
}
func (s *bytesFilter) Contains(b []byte) bool { func (s *bytesFilter) Contains(b []byte) bool {
l := len(b) l := len(b)
m := s.threshold m := s.threshold

4
vendor/modules.txt vendored
View File

@ -946,8 +946,8 @@ github.com/vmihailenco/tagparser/v2/internal/parser
# github.com/wagslane/go-password-validator v0.3.0 # github.com/wagslane/go-password-validator v0.3.0
## explicit; go 1.16 ## explicit; go 1.16
github.com/wagslane/go-password-validator github.com/wagslane/go-password-validator
# github.com/yuin/goldmark v1.7.8 # github.com/yuin/goldmark v1.7.10
## explicit; go 1.19 ## explicit; go 1.22
github.com/yuin/goldmark github.com/yuin/goldmark
github.com/yuin/goldmark/ast github.com/yuin/goldmark/ast
github.com/yuin/goldmark/extension github.com/yuin/goldmark/extension