✨ Chat > Add HTML entities
This commit is contained in:
+4
-2
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
const ids = require('./ids.js')
|
const ids = require('./ids.js')
|
||||||
const robotNames = require('./robot-names.json')
|
const robotNames = require('./robot-names.json')
|
||||||
|
const HTMLEntities = require('html-entities')
|
||||||
|
|
||||||
class Chat
|
class Chat
|
||||||
{
|
{
|
||||||
@@ -12,6 +13,7 @@ class Chat
|
|||||||
this.users = {}
|
this.users = {}
|
||||||
this.messages = []
|
this.messages = []
|
||||||
this.availableRobotNames = this.shuffle(robotNames.slice())
|
this.availableRobotNames = this.shuffle(robotNames.slice())
|
||||||
|
this.htmlEntities = new HTMLEntities.XmlEntities()
|
||||||
|
|
||||||
this.setSocket()
|
this.setSocket()
|
||||||
}
|
}
|
||||||
@@ -52,7 +54,7 @@ class Chat
|
|||||||
const broadcastMessage = {}
|
const broadcastMessage = {}
|
||||||
broadcastMessage.id = data.id
|
broadcastMessage.id = data.id
|
||||||
broadcastMessage.time = data.time
|
broadcastMessage.time = data.time
|
||||||
broadcastMessage.text = data.text
|
broadcastMessage.text = this.htmlEntities.encode(data.text)
|
||||||
broadcastMessage.file = data.file
|
broadcastMessage.file = data.file
|
||||||
broadcastMessage.line = data.line
|
broadcastMessage.line = data.line
|
||||||
broadcastMessage.user = user
|
broadcastMessage.user = user
|
||||||
@@ -79,7 +81,7 @@ class Chat
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update name
|
// Update name
|
||||||
user.name = data.name
|
user.name = this.htmlEntities.encode(data.name)
|
||||||
|
|
||||||
// Debug
|
// Debug
|
||||||
if(this.config.debug >= 1)
|
if(this.config.debug >= 1)
|
||||||
|
|||||||
+3
-3
@@ -180,15 +180,15 @@ class Site
|
|||||||
|
|
||||||
const $author = document.createElement('div')
|
const $author = document.createElement('div')
|
||||||
$author.style.color = data.user.color
|
$author.style.color = data.user.color
|
||||||
$author.innerText = data.user.name
|
$author.innerHTML = data.user.name
|
||||||
$message.appendChild($author)
|
$message.appendChild($author)
|
||||||
|
|
||||||
const $info = document.createElement('div')
|
const $info = document.createElement('div')
|
||||||
$info.innerText = data.file + ':' + data.line
|
$info.innerHTML = data.file + ':' + data.line
|
||||||
$message.appendChild($info)
|
$message.appendChild($info)
|
||||||
|
|
||||||
const $text = document.createElement('div')
|
const $text = document.createElement('div')
|
||||||
$text.innerText = data.text
|
$text.innerHTML = data.text
|
||||||
$message.appendChild($text)
|
$message.appendChild($text)
|
||||||
|
|
||||||
$messages.appendChild($message)
|
$messages.appendChild($message)
|
||||||
|
|||||||
Generated
+5
@@ -1936,6 +1936,11 @@
|
|||||||
"core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz"
|
"core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"html-entities": {
|
||||||
|
"version": "1.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/html-entities/-/html-entities-1.2.1.tgz",
|
||||||
|
"integrity": "sha1-DfKTUfByEWNRXfueVUPl9u7VFi8="
|
||||||
|
},
|
||||||
"http-errors": {
|
"http-errors": {
|
||||||
"version": "https://registry.npmjs.org/http-errors/-/http-errors-1.5.1.tgz",
|
"version": "https://registry.npmjs.org/http-errors/-/http-errors-1.5.1.tgz",
|
||||||
"integrity": "sha1-eIwNLB3iyBuebowBhDtrl+uSB1A=",
|
"integrity": "sha1-eIwNLB3iyBuebowBhDtrl+uSB1A=",
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
"express": "^4.13.4",
|
"express": "^4.13.4",
|
||||||
"glob": "^7.1.2",
|
"glob": "^7.1.2",
|
||||||
"helmet": "^2.1.0",
|
"helmet": "^2.1.0",
|
||||||
|
"html-entities": "^1.2.1",
|
||||||
"ip": "^1.1.3",
|
"ip": "^1.1.3",
|
||||||
"mime": "^1.3.4",
|
"mime": "^1.3.4",
|
||||||
"minimatch": "^3.0.3",
|
"minimatch": "^3.0.3",
|
||||||
|
|||||||
Reference in New Issue
Block a user