Fix emote regex due to sanitize-html changes

This commit is contained in:
Calvin Montgomery 2017-03-14 21:36:44 -07:00
parent 9239c2d465
commit f6500ff745
3 changed files with 11 additions and 2 deletions

View File

@ -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": "3.34.0", "version": "3.34.1",
"repository": { "repository": {
"url": "http://github.com/calzoneman/sync" "url": "http://github.com/calzoneman/sync"
}, },

View File

@ -75,7 +75,7 @@ function validateEmote(f) {
f.image = f.image.substring(0, 1000); f.image = f.image.substring(0, 1000);
f.image = XSS.sanitizeText(f.image); f.image = XSS.sanitizeText(f.image);
var s = XSS.sanitizeText(f.name).replace(/([\\\.\?\+\*\$\^\|\(\)\[\]\{\}])/g, "\\$1"); var s = XSS.looseSanitizeText(f.name).replace(/([\\\.\?\+\*\$\^\|\(\)\[\]\{\}])/g, "\\$1");
s = "(^|\\s)" + s + "(?!\\S)"; s = "(^|\\s)" + s + "(?!\\S)";
f.source = s; f.source = s;

View File

@ -70,6 +70,14 @@ const SETTINGS = {
allowedAttributes: ATTRIBUTE_MAP allowedAttributes: ATTRIBUTE_MAP
}; };
function looseSanitizeText(str) {
str = str.replace(/&/g, "&")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;");
return str;
}
function sanitizeText(str) { function sanitizeText(str) {
str = str.replace(/&/g, "&amp;") str = str.replace(/&/g, "&amp;")
.replace(/</g, "&lt;") .replace(/</g, "&lt;")
@ -99,5 +107,6 @@ module.exports.sanitizeHTML = function (html) {
return sanitizeHTML(html, SETTINGS); return sanitizeHTML(html, SETTINGS);
}; };
module.exports.looseSanitizeText = looseSanitizeText;
module.exports.sanitizeText = sanitizeText; module.exports.sanitizeText = sanitizeText;
module.exports.decodeText = decodeText; module.exports.decodeText = decodeText;