1
0
mirror of https://github.com/thomiceli/opengist synced 2024-11-08 12:55:50 +01:00

Fix new line literal in embed (#237)

This commit is contained in:
Thomas Miceli 2024-04-02 17:12:29 +02:00
parent 1c1e3a8919
commit c185cb8933

@ -443,8 +443,9 @@ func gistJs(ctx echo.Context) error {
js := `document.write('<link rel="stylesheet" href="%s">') js := `document.write('<link rel="stylesheet" href="%s">')
document.write('%s') document.write('%s')
` `
js = fmt.Sprintf(js, cssUrl, content := strings.Replace(htmlbuf.String(), `\n`, `\\n`, -1)
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") ctx.Response().Header().Set("Content-Type", "application/javascript")
return plainText(ctx, 200, js) return plainText(ctx, 200, js)
} }