Render and sanitize chat messages server-side. (#237)

* Render and sanitize chat messages server-side. Closes #235

* Render content.md server-side and return it in the client config

* Remove showdown from web project

* Update api spec

* Move example user content file
This commit is contained in:
Gabe Kangas
2020-10-13 16:45:52 -07:00
committed by GitHub
parent 9eab6d7553
commit d7c3991b59
23 changed files with 408 additions and 5441 deletions

View File

@@ -110,10 +110,17 @@ func (s *server) Listen() {
delete(s.Clients, c.socketID)
s.listener.ClientRemoved(c.ClientID)
// broadcast a message to all clients
// message was recieved from a client and should be sanitized, validated
// and distributed to other clients.
case msg := <-s.sendAllCh:
// Will turn markdown into html, sanitize user-supplied raw html
// and standardize this message into something safe we can send everyone else.
msg.RenderAndSanitizeMessageBody()
s.listener.MessageSent(msg)
s.sendAll(msg)
// Store in the message history
addMessage(msg)
case ping := <-s.pingCh:
fmt.Println("PING?", ping)