1
0
mirror of https://github.com/schollz/cowyo.git synced 2023-08-10 21:13:00 +03:00

Supports base64 images now

This commit is contained in:
Zack Scholl 2016-02-08 20:05:29 -05:00
parent 05cf475742
commit 8019335da0
2 changed files with 7 additions and 2 deletions

View File

@ -77,7 +77,12 @@ func serveStaticFile(c *gin.Context, option string) {
func renderMarkdown(c *gin.Context, currentText string, title string) { func renderMarkdown(c *gin.Context, currentText string, title string) {
unsafe := blackfriday.MarkdownCommon([]byte(currentText)) 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) html2 := string(html)
r, _ := regexp.Compile("\\$\\$(.*?)\\$\\$") r, _ := regexp.Compile("\\$\\$(.*?)\\$\\$")
for _, s := range r.FindAllString(html2, -1) { for _, s := range r.FindAllString(html2, -1) {

View File

@ -34,7 +34,7 @@
body { body {
margin: 0; margin: 0;
background: #fff; background: #fff;
max-width: 700px; max-width: 800px;
margin: 0 auto; margin: 0 auto;
} }