From 8019335da08dced8b10b28b49358de2924512bbb Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Mon, 8 Feb 2016 20:05:29 -0500 Subject: [PATCH] Supports base64 images now --- routes.go | 7 ++++++- templates/index.tmpl | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/routes.go b/routes.go index c41af4d..9da27d1 100644 --- a/routes.go +++ b/routes.go @@ -77,7 +77,12 @@ func serveStaticFile(c *gin.Context, option string) { func renderMarkdown(c *gin.Context, currentText string, title string) { unsafe := blackfriday.MarkdownCommon([]byte(currentText)) - html := bluemonday.UGCPolicy().SanitizeBytes(unsafe) + pClean := bluemonday.UGCPolicy() + pClean.AllowElements("img") + pClean.AllowAttrs("alt").OnElements("img") + pClean.AllowAttrs("src").OnElements("img") + pClean.AllowDataURIImages() + html := pClean.SanitizeBytes(unsafe) html2 := string(html) r, _ := regexp.Compile("\\$\\$(.*?)\\$\\$") for _, s := range r.FindAllString(html2, -1) { diff --git a/templates/index.tmpl b/templates/index.tmpl index 2a645ba..583c0a0 100644 --- a/templates/index.tmpl +++ b/templates/index.tmpl @@ -34,7 +34,7 @@ body { margin: 0; background: #fff; - max-width: 700px; + max-width: 800px; margin: 0 auto; }