Permalink
Browse files

Santizing html

  • Loading branch information...
1 parent 2355107 commit 60cbb83b5e0b236579e933e3c85448871c435ed8 @jeregrine committed Feb 5, 2012
Showing with 5 additions and 8 deletions.
  1. +2 −1 package.json
  2. +3 −7 server.coffee
View
@@ -11,5 +11,6 @@
,"underscore": ">= 0.0.1"
,"socket.io": ">= 0.0.1"
,"coffee-script": "1.1.2"
+ ,"validator": ">= 0.0.1"
}
-}
+}
View
@@ -1,18 +1,15 @@
express = require 'express'
app = express.createServer()
_ = require 'underscore'
+sanitize = require('validator').sanitize
io = require('socket.io').listen(app)
io.configure ()->
io.set("transports", ["xhr-polling"])
io.set("polling duration", 10)
-escape = (html)->
- new String(html)
- .replace(/&(?!\w+;)/g, '&')
- .replace(/</g, '&lt;')
- .replace(/>/g, '&gt;')
- .replace(/"/g, '&quot;')
+escape = (str)->
+ sanitize(str).entityEncode()
colors = _.shuffle(["#8FBF4D", "#0D8C7F", "#063559", "#F2D13E", "#D95929"])
used = []
@@ -27,7 +24,6 @@ releaseColor = (color) ->
c = used[index]
colors.push(color)
used.splice(index,1)
- console.log used
getClients = ()->
_.map io.sockets.clients(), (c)->

0 comments on commit 60cbb83

Please sign in to comment.