1
0
Fork 0
forked from forgejo/forgejo

Fix task list checkbox toggle to work with YAML front matter (#25184) (#25236)

Backport https://github.com/go-gitea/gitea/pull/25184 by @jtran
Closes #25225.

Fixes https://github.com/go-gitea/gitea/issues/25160.

`data-source-position` of checkboxes in a task list was incorrect
whenever there was YAML front matter. This would result in issue content
or PR descriptions getting corrupted with random `x` or space characters
when a user checked or unchecked a task.

(cherry picked from commit 1650a26eb5)
This commit is contained in:
Jonathan Tran 2023-06-13 14:22:59 -04:00 committed by Earl Warren
parent 38e5589bd6
commit c34b605314
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
6 changed files with 66 additions and 7 deletions

View file

@ -173,6 +173,9 @@ func actualRender(ctx *markup.RenderContext, input io.Reader, output io.Writer)
}
buf = giteautil.NormalizeEOL(buf)
// Preserve original length.
bufWithMetadataLength := len(buf)
rc := &RenderConfig{
Meta: "table",
Icon: "table",
@ -180,6 +183,12 @@ func actualRender(ctx *markup.RenderContext, input io.Reader, output io.Writer)
}
buf, _ = ExtractMetadataBytes(buf, rc)
metaLength := bufWithMetadataLength - len(buf)
if metaLength < 0 {
metaLength = 0
}
rc.metaLength = metaLength
pc.Set(renderConfigKey, rc)
if err := converter.Convert(buf, lw, parser.WithContext(pc)); err != nil {