Ver Fonte

mailer: fix template not found error

ᴜɴᴋɴᴡᴏɴ há 5 anos atrás
pai
commit
f85b17a00e
3 ficheiros alterados com 3 adições e 0 exclusões
  1. 1 0
      CHANGELOG.md
  2. 1 0
      internal/assets/templates/templates.go
  3. 1 0
      internal/mailer/mail.go

+ 1 - 0
CHANGELOG.md

@@ -18,6 +18,7 @@ All notable changes to Gogs are documented in this file.
 
 ### Fixed
 
+- [Security] Potential open redirection with i18n.
 - [Security] Potential RCE on mirror repositories. [#5767](https://github.com/gogs/gogs/issues/5767)
 - [Security] Potential XSS attack with raw markdown API. [#5907](https://github.com/gogs/gogs/pull/5907)
 - Open/close milestone redirects to a 404 page. [#5677](https://github.com/gogs/gogs/issues/5677)

+ 1 - 0
internal/assets/templates/templates.go

@@ -65,6 +65,7 @@ func NewTemplateFileSystem(dir, customDir string) macaron.TemplateFileSystem {
 			panic(err)
 		}
 
+		name = strings.TrimPrefix(name, dir)
 		ext := path.Ext(name)
 		name = strings.TrimSuffix(name, ext)
 		files = append(files, macaron.NewTplFile(name, data, ext))

+ 1 - 0
internal/mailer/mail.go

@@ -43,6 +43,7 @@ func render(tpl string, data map[string]interface{}) (string, error) {
 		opt := &macaron.RenderOptions{
 			Directory:         path.Join(setting.StaticRootPath, "templates/mail"),
 			AppendDirectories: []string{path.Join(setting.CustomPath, "templates/mail")},
+			Extensions:        []string{".tmpl", ".html"},
 			Funcs: []template.FuncMap{map[string]interface{}{
 				"AppName": func() string {
 					return setting.AppName