mirror of https://github.com/calzoneman/sync.git
Better XSS prevention (NOTE: must run npm install validator on existing installs)
This commit is contained in:
parent
46b823c60d
commit
91a2fcb61d
|
@ -25,6 +25,7 @@ var Auth = require("./auth.js");
|
||||||
var ChatCommand = require("./chatcommand.js");
|
var ChatCommand = require("./chatcommand.js");
|
||||||
var Filter = require("./filter.js").Filter;
|
var Filter = require("./filter.js").Filter;
|
||||||
var ActionLog = require("./actionlog");
|
var ActionLog = require("./actionlog");
|
||||||
|
var sanitize = require("validator").sanitize;
|
||||||
|
|
||||||
var Channel = function(name) {
|
var Channel = function(name) {
|
||||||
Logger.syslog.log("Opening channel " + name);
|
Logger.syslog.log("Opening channel " + name);
|
||||||
|
@ -1594,6 +1595,7 @@ Channel.prototype.tryUpdateFilter = function(user, f) {
|
||||||
|
|
||||||
var re = f.source;
|
var re = f.source;
|
||||||
var flags = f.flags;
|
var flags = f.flags;
|
||||||
|
f.replace = sanitize(f.replace).xss();
|
||||||
try {
|
try {
|
||||||
new RegExp(re, flags);
|
new RegExp(re, flags);
|
||||||
}
|
}
|
||||||
|
@ -1696,6 +1698,7 @@ Channel.prototype.trySetJS = function(user, data) {
|
||||||
|
|
||||||
Channel.prototype.updateMotd = function(motd) {
|
Channel.prototype.updateMotd = function(motd) {
|
||||||
var html = motd.replace(/\n/g, "<br>");
|
var html = motd.replace(/\n/g, "<br>");
|
||||||
|
html = sanitize(html).xss();
|
||||||
//html = this.filterMessage(html);
|
//html = this.filterMessage(html);
|
||||||
this.motd = {
|
this.motd = {
|
||||||
motd: motd,
|
motd: motd,
|
||||||
|
@ -1782,8 +1785,7 @@ Channel.prototype.filterMessage = function(msg) {
|
||||||
|
|
||||||
Channel.prototype.sendMessage = function(username, msg, msgclass, data) {
|
Channel.prototype.sendMessage = function(username, msg, msgclass, data) {
|
||||||
// I don't want HTML from strangers
|
// I don't want HTML from strangers
|
||||||
msg = msg.replace(/&/g, "&");
|
msg = sanitize(msg).escape();
|
||||||
msg = msg.replace(/</g, "<").replace(/>/g, ">");
|
|
||||||
msg = this.filterMessage(msg);
|
msg = this.filterMessage(msg);
|
||||||
var msgobj = {
|
var msgobj = {
|
||||||
username: username,
|
username: username,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"author": "Calvin Montgomery",
|
"author": "Calvin Montgomery",
|
||||||
"name": "CyTube",
|
"name": "CyTube",
|
||||||
"description": "Online media synchronizer and chat",
|
"description": "Online media synchronizer and chat",
|
||||||
"version": "2.0.1",
|
"version": "2.0.2",
|
||||||
"repository": {
|
"repository": {
|
||||||
"url": "http://github.com/calzoneman/sync"
|
"url": "http://github.com/calzoneman/sync"
|
||||||
},
|
},
|
||||||
|
@ -12,6 +12,7 @@
|
||||||
"mysql-libmysqlclient": "*",
|
"mysql-libmysqlclient": "*",
|
||||||
"node_hash": "*",
|
"node_hash": "*",
|
||||||
"bcrypt": "*",
|
"bcrypt": "*",
|
||||||
"nodemailer": "*"
|
"nodemailer": "*",
|
||||||
|
"validator": "*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ The above copyright notice and this permission notice shall be included in all c
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const VERSION = "2.0.1";
|
const VERSION = "2.0.2";
|
||||||
|
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
var Logger = require("./logger.js");
|
var Logger = require("./logger.js");
|
||||||
|
|
|
@ -106,8 +106,9 @@ Callbacks = {
|
||||||
|
|
||||||
setMotd: function(data) {
|
setMotd: function(data) {
|
||||||
CHANNEL.motd = data.html;
|
CHANNEL.motd = data.html;
|
||||||
|
CHANNEL.motd_text = data.motd;
|
||||||
$("#motd").html(data.html);
|
$("#motd").html(data.html);
|
||||||
$("#motdtext").val(CHANNEL.motd);
|
$("#motdtext").val(CHANNEL.motd_text);
|
||||||
if(data.motd != "")
|
if(data.motd != "")
|
||||||
$("#motd").show();
|
$("#motd").show();
|
||||||
else
|
else
|
||||||
|
|
|
@ -29,6 +29,7 @@ var CHANNEL = {
|
||||||
css: "",
|
css: "",
|
||||||
js: "",
|
js: "",
|
||||||
motd: "",
|
motd: "",
|
||||||
|
motd_text: "",
|
||||||
name: false
|
name: false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -767,7 +767,7 @@ function handleModPermissions() {
|
||||||
$("#opt_voteskip_ratio").val(CHANNEL.opts.voteskip_ratio);
|
$("#opt_voteskip_ratio").val(CHANNEL.opts.voteskip_ratio);
|
||||||
$("#csstext").val(CHANNEL.css);
|
$("#csstext").val(CHANNEL.css);
|
||||||
$("#jstext").val(CHANNEL.js);
|
$("#jstext").val(CHANNEL.js);
|
||||||
$("#motdtext").val(CHANNEL.motd);
|
$("#motdtext").val(CHANNEL.motd_text);
|
||||||
setVisible("#permedit_tab", CLIENT.rank >= 3);
|
setVisible("#permedit_tab", CLIENT.rank >= 3);
|
||||||
setVisible("#banlist_tab", hasPermission("ban"));
|
setVisible("#banlist_tab", hasPermission("ban"));
|
||||||
setVisible("#motdedit_tab", hasPermission("motdedit"));
|
setVisible("#motdedit_tab", hasPermission("motdedit"));
|
||||||
|
|
Loading…
Reference in New Issue