Skip to content

Commit 31ad8b7

Browse files
lunnytechknowlogick
authored andcommitted
Fix wrong init dependency on markup extensions (#7038) (#7074)
* fix wrong init dependency on markup extensions
1 parent d07edc5 commit 31ad8b7

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"
@@ -120,8 +119,6 @@ func runWeb(ctx *cli.Context) error {
120119

121120
routers.GlobalInit()
122121

123-
external.RegisterParsers()
124-
125122
m := routes.NewMacaron()
126123
routes.RegisterRoutes(m)
127124

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
@@ -19,6 +19,7 @@ import (
1919
"code.gitea.io/gitea/modules/log"
2020
"code.gitea.io/gitea/modules/mailer"
2121
"code.gitea.io/gitea/modules/markup"
22+
"code.gitea.io/gitea/modules/markup/external"
2223
"code.gitea.io/gitea/modules/setting"
2324
"code.gitea.io/gitea/modules/ssh"
2425

@@ -75,6 +76,7 @@ func GlobalInit() {
7576

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

0 commit comments

Comments
 (0)