From 99271119e8917bc31540ef69081b7dc57317a886 Mon Sep 17 00:00:00 2001 From: tinqs-limited Date: Wed, 20 May 2026 09:58:06 +0100 Subject: [PATCH] fix: force-clear template data for HTML files to show iframe Co-authored-by: Cursor --- routers/web/repo/view_file.go | 10 ++++++++++ 1 file changed, 10 insertions(+) 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