forked from forgejo/forgejo
[BUG] Fix crash in issue forms
- Fix a crash in the issue forms, because `ctx.Ctx` was trying to be accessed, however this is not set in all contexts thus could result to NPE. - Adds integration test. - Resolves #3011
This commit is contained in:
parent
5951c9b2c4
commit
b0cd0ebb91
2 changed files with 57 additions and 3 deletions
|
@ -1065,9 +1065,12 @@ func filePreviewPatternProcessor(ctx *RenderContext, node *html.Node) {
|
|||
|
||||
next := node.NextSibling
|
||||
for node != nil && node != next {
|
||||
locale, ok := ctx.Ctx.Value(translation.ContextKey).(translation.Locale)
|
||||
if !ok {
|
||||
locale = translation.NewLocale("en-US")
|
||||
locale := translation.NewLocale("en-US")
|
||||
if ctx.Ctx != nil {
|
||||
ctxLocale, ok := ctx.Ctx.Value(translation.ContextKey).(translation.Locale)
|
||||
if ok {
|
||||
locale = ctxLocale
|
||||
}
|
||||
}
|
||||
|
||||
preview := NewFilePreview(ctx, node, locale)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue