From c185cb89333f350cef962d8f96d79a3ca080db99 Mon Sep 17 00:00:00 2001 From: Thomas Miceli <27960254+thomiceli@users.noreply.github.com> Date: Tue, 2 Apr 2024 17:12:29 +0200 Subject: [PATCH] Fix new line literal in embed (#237) --- internal/web/gist.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/web/gist.go b/internal/web/gist.go index e53d064..698a0da 100644 --- a/internal/web/gist.go +++ b/internal/web/gist.go @@ -443,8 +443,9 @@ func gistJs(ctx echo.Context) error { js := `document.write('') document.write('%s') ` - js = fmt.Sprintf(js, cssUrl, - strings.Replace(htmlbuf.String(), "\n", `\n`, -1)) + content := strings.Replace(htmlbuf.String(), `\n`, `\\n`, -1) + content = strings.Replace(content, "\n", `\n`, -1) + js = fmt.Sprintf(js, cssUrl, content) ctx.Response().Header().Set("Content-Type", "application/javascript") return plainText(ctx, 200, js) }