Skip to content

Commit 53c5469

Browse files
wxiaoguangearl-warren
authored andcommitted
Fix and refactor markdown rendering (go-gitea#32522)
(cherry picked from commit 5eebe1d) Conflicts: models/repo/repo.go models/repo/repo_test.go modules/markup/html.go modules/markup/html_commit.go modules/markup/html_email.go modules/markup/html_emoji.go modules/markup/html_internal_test.go modules/markup/html_issue.go modules/markup/html_link.go modules/markup/html_node.go modules/markup/html_test.go modules/markup/markdown/goldmark.go modules/markup/markdown/markdown_test.go modules/markup/markdown/transform_image.go modules/markup/orgmode/orgmode.go modules/markup/orgmode/orgmode_test.go modules/markup/render.go modules/markup/render_links.go modules/templates/util_render.go modules/templates/util_render_test.go routers/common/markup.go routers/web/feed/convert.go routers/web/repo/wiki.go but a few lines survived and are useful
1 parent 8cec637 commit 53c5469

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

modules/markup/asciicast/asciicast.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const (
3939
// SanitizerRules implements markup.Renderer
4040
func (Renderer) SanitizerRules() []setting.MarkupSanitizerRule {
4141
return []setting.MarkupSanitizerRule{
42-
{Element: "div", AllowAttr: "class", Regexp: regexp.MustCompile(playerClassName)},
42+
{Element: "div", AllowAttr: "class", Regexp: regexp.MustCompile("^" + playerClassName + "$")},
4343
{Element: "div", AllowAttr: playerSrcAttr},
4444
}
4545
}

modules/markup/csv/csv.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ func (Renderer) Extensions() []string {
3737
// SanitizerRules implements markup.Renderer
3838
func (Renderer) SanitizerRules() []setting.MarkupSanitizerRule {
3939
return []setting.MarkupSanitizerRule{
40-
{Element: "table", AllowAttr: "class", Regexp: regexp.MustCompile(`data-table`)},
41-
{Element: "th", AllowAttr: "class", Regexp: regexp.MustCompile(`line-num`)},
42-
{Element: "td", AllowAttr: "class", Regexp: regexp.MustCompile(`line-num`)},
40+
{Element: "table", AllowAttr: "class", Regexp: regexp.MustCompile(`^data-table$`)},
41+
{Element: "th", AllowAttr: "class", Regexp: regexp.MustCompile(`^line-num$`)},
42+
{Element: "td", AllowAttr: "class", Regexp: regexp.MustCompile(`^line-num$`)},
4343
}
4444
}
4545

0 commit comments

Comments
 (0)