From 62f7290a38413bc234205269c9e36174c0112db6 Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Sat, 6 Feb 2016 23:16:16 -0500 Subject: [PATCH] Edit Former-commit-id: 209a34ecc2abab0c1a6ef56c9f5e21a79a986de9 [formerly a69b67830e88f14165acd5436297ea4d0e212f67] [formerly 45f25c5bbf87e01ff782cf557365ec954ae19db7 [formerly 6c5a4296094e29d4986ba52f656288ed5d68b518 [formerly 205235c4eaafd4ecdbc27275ebe9cded0390dc39]]] Former-commit-id: 60ba3ebd7b02e9f09db200acf0f69b480626d308 [formerly 472f73d442462927668c103eda77bbc818735805] Former-commit-id: 932fb7186f2a142f2ee69e4f5c8ac4cc47471705 Former-commit-id: affe63305319f55f92f9b8c15098406739635f9d --- main.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/main.go b/main.go index 1648c29..7c9f806 100755 --- a/main.go +++ b/main.go @@ -13,6 +13,8 @@ import ( "github.com/boltdb/bolt" "github.com/gin-gonic/gin" "github.com/gorilla/websocket" + "github.com/microcosm-cc/bluemonday" + "github.com/russross/blackfriday" ) var db *bolt.DB @@ -140,6 +142,16 @@ func main() { option := c.Param("option") fmt.Println(title, "["+option+"]") if option == "/view" { + p := CowyoData{title, ""} + err := p.load() + if err != nil { + panic(err) + } + + unsafe := blackfriday.MarkdownCommon([]byte(p.Text)) + html := bluemonday.UGCPolicy().SanitizeBytes(unsafe) + c.Data(200, "text/html", html) + } else { c.Redirect(302, "/"+title) }