From aec437475bb4707ef4702f5dc8a7104cc20b5f06 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 Former-commit-id: 1b543f804e763ac073ee76d3f8587d5a2ced1144 [formerly c01054eb87a0cb9738b529be9ca82d5a31c7d1b9] [formerly d9c64547e374965a8fbdad17ee9130f8bace0a38 [formerly 2b6303549e28f99fc514957e1dbfd591922039b6 [formerly 8019335da08dced8b10b28b49358de2924512bbb]]] Former-commit-id: d5aae886478027d51bb4d75d17205f00509b4c5a [formerly 2d6dc42d8e610ed5823b3747d2167ba3231360e3] Former-commit-id: 6f0055b5e2336ead2974ad79e5759c0d67a75566 Former-commit-id: 6f39dab8d67e4d1eb4df7cf43716d92ced4b0f68 --- 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; }