diff --git a/routers/web/repo/view_file.go b/routers/web/repo/view_file.go index f8a7c254ab..ea92f07d5b 100644 --- a/routers/web/repo/view_file.go +++ b/routers/web/repo/view_file.go @@ -254,6 +254,16 @@ func prepareFileView(ctx *context.Context, entry *git.TreeEntry) { case fInfo.blobOrLfsSize >= setting.UI.MaxDisplayFileSize: ctx.Data["IsFileTooLarge"] = true case handleFileViewRenderHTML(ctx, fInfo): + // ALL debug logs and template data are correct, but the template renders source. + // FORCE iframe rendering: override FileContent so template skips source view. + ctx.Data["IsImageFile"] = false + ctx.Data["IsVideoFile"] = false + ctx.Data["IsAudioFile"] = false + // Clear any FileContent that might have leaked + delete(ctx.Data, "FileContent") + delete(ctx.Data, "RenderAsMarkup") + delete(ctx.Data, "IsPlainText") + delete(ctx.Data, "IsDisplayingSource") case handleFileViewRenderMarkup(ctx, buf, contentReader): case handleFileViewRenderSource(ctx, attrs, fInfo, contentReader): // it also sets ctx.Data["FileContent"] and more