Skip to content

Commit 824dd00

Browse files
lunnyjeffliu27
authored andcommitted
Fix wrong init dependency on markup extensions (go-gitea#7038)
* fix wrong init dependency on markup extensions
1 parent 0f1bb60 commit 824dd00

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

cmd/web.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"strings"
1616

1717
"code.gitea.io/gitea/modules/log"
18-
"code.gitea.io/gitea/modules/markup/external"
1918
"code.gitea.io/gitea/modules/setting"
2019
"code.gitea.io/gitea/routers"
2120
"code.gitea.io/gitea/routers/routes"
@@ -111,8 +110,6 @@ func runWeb(ctx *cli.Context) error {
111110

112111
routers.GlobalInit()
113112

114-
external.RegisterParsers()
115-
116113
m := routes.NewMacaron()
117114
routes.RegisterRoutes(m)
118115

contrib/pr/checkout.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"strconv"
2121
"time"
2222

23+
"code.gitea.io/gitea/modules/markup"
2324
"code.gitea.io/gitea/modules/markup/external"
2425
"code.gitea.io/gitea/routers"
2526
"code.gitea.io/gitea/routers/routes"
@@ -113,6 +114,7 @@ func runPR() {
113114
log.Printf("[PR] Setting up router\n")
114115
//routers.GlobalInit()
115116
external.RegisterParsers()
117+
markup.Init()
116118
m := routes.NewMacaron()
117119
routes.RegisterRoutes(m)
118120

modules/markup/markup.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ import (
1515
func Init() {
1616
getIssueFullPattern()
1717
NewSanitizer()
18+
19+
// since setting maybe changed extensions, this will reload all parser extensions mapping
20+
extParsers = make(map[string]Parser)
21+
for _, parser := range parsers {
22+
for _, ext := range parser.Extensions() {
23+
extParsers[strings.ToLower(ext)] = parser
24+
}
25+
}
1826
}
1927

2028
// Parser defines an interface for parsering markup file to HTML

routers/init.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"code.gitea.io/gitea/modules/log"
2121
"code.gitea.io/gitea/modules/mailer"
2222
"code.gitea.io/gitea/modules/markup"
23+
"code.gitea.io/gitea/modules/markup/external"
2324
"code.gitea.io/gitea/modules/setting"
2425
"code.gitea.io/gitea/modules/ssh"
2526

@@ -76,6 +77,7 @@ func GlobalInit() {
7677

7778
if setting.InstallLock {
7879
highlight.NewContext()
80+
external.RegisterParsers()
7981
markup.Init()
8082
if err := initDBEngine(); err == nil {
8183
log.Info("ORM engine initialization successful!")

0 commit comments

Comments
 (0)