Skip to content

Commit

Permalink
Fix wrong init dependency on markup extensions (go-gitea#7038)
Browse files Browse the repository at this point in the history
* fix wrong init dependency on markup extensions
  • Loading branch information
lunny authored and zeripath committed May 25, 2019
1 parent 0c432d2 commit 355ab0c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
3 changes: 0 additions & 3 deletions cmd/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"strings"

"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/markup/external"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/routers"
"code.gitea.io/gitea/routers/routes"
Expand Down Expand Up @@ -111,8 +110,6 @@ func runWeb(ctx *cli.Context) error {

routers.GlobalInit()

external.RegisterParsers()

m := routes.NewMacaron()
routes.RegisterRoutes(m)

Expand Down
2 changes: 2 additions & 0 deletions contrib/pr/checkout.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"strconv"
"time"

"code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/markup/external"
"code.gitea.io/gitea/routers"
"code.gitea.io/gitea/routers/routes"
Expand Down Expand Up @@ -113,6 +114,7 @@ func runPR() {
log.Printf("[PR] Setting up router\n")
//routers.GlobalInit()
external.RegisterParsers()
markup.Init()
m := routes.NewMacaron()
routes.RegisterRoutes(m)

Expand Down
8 changes: 8 additions & 0 deletions modules/markup/markup.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ import (
func Init() {
getIssueFullPattern()
NewSanitizer()

// since setting maybe changed extensions, this will reload all parser extensions mapping
extParsers = make(map[string]Parser)
for _, parser := range parsers {
for _, ext := range parser.Extensions() {
extParsers[strings.ToLower(ext)] = parser
}
}
}

// Parser defines an interface for parsering markup file to HTML
Expand Down
2 changes: 2 additions & 0 deletions routers/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/mailer"
"code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/markup/external"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/ssh"

Expand Down Expand Up @@ -75,6 +76,7 @@ func GlobalInit() {

if setting.InstallLock {
highlight.NewContext()
external.RegisterParsers()
markup.Init()
if err := initDBEngine(); err == nil {
log.Info("ORM engine initialization successful!")
Expand Down

0 comments on commit 355ab0c

Please sign in to comment.