Disable HTML in chat
This commit is contained in:
parent
22f1ac9e1e
commit
3a4cfbb7e8
@ -28,12 +28,17 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
Marked.setOptions({
|
Marked.setOptions({
|
||||||
|
//sanitize: true, // Disable HTML
|
||||||
renderer: renderer,
|
renderer: renderer,
|
||||||
highlight: highlighter(),
|
highlight: highlighter(),
|
||||||
});
|
});
|
||||||
|
|
||||||
DiffMd.render = function (md) {
|
|
||||||
return Marked(md);
|
|
||||||
|
DiffMd.render = function (md, sanitize) {
|
||||||
|
return Marked(md, {
|
||||||
|
sanitize: sanitize
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var mediaMap = {};
|
var mediaMap = {};
|
||||||
@ -103,6 +108,7 @@ define([
|
|||||||
'APPLET',
|
'APPLET',
|
||||||
'VIDEO', // privacy implications of videos are the same as images
|
'VIDEO', // privacy implications of videos are the same as images
|
||||||
'AUDIO', // same with audio
|
'AUDIO', // same with audio
|
||||||
|
'SVG'
|
||||||
];
|
];
|
||||||
var unsafeTag = function (info) {
|
var unsafeTag = function (info) {
|
||||||
/*if (info.node && $(info.node).parents('media-tag').length) {
|
/*if (info.node && $(info.node).parents('media-tag').length) {
|
||||||
@ -117,10 +123,10 @@ define([
|
|||||||
}
|
}
|
||||||
if (['addElement', 'replaceElement'].indexOf(info.diff.action) !== -1) {
|
if (['addElement', 'replaceElement'].indexOf(info.diff.action) !== -1) {
|
||||||
var msg = "Rejecting forbidden tag of type (%s)";
|
var msg = "Rejecting forbidden tag of type (%s)";
|
||||||
if (info.diff.element && forbiddenTags.indexOf(info.diff.element.nodeName) !== -1) {
|
if (info.diff.element && forbiddenTags.indexOf(info.diff.element.nodeName.toUpperCase()) !== -1) {
|
||||||
console.log(msg, info.diff.element.nodeName);
|
console.log(msg, info.diff.element.nodeName);
|
||||||
return true;
|
return true;
|
||||||
} else if (info.diff.newValue && forbiddenTags.indexOf(info.diff.newValue.nodeName) !== -1) {
|
} else if (info.diff.newValue && forbiddenTags.indexOf(info.diff.newValue.nodeName.toUpperCase()) !== -1) {
|
||||||
console.log("Replacing restricted element type (%s) with PRE", info.diff.newValue.nodeName);
|
console.log("Replacing restricted element type (%s) with PRE", info.diff.newValue.nodeName);
|
||||||
info.diff.newValue.nodeName = 'PRE';
|
info.diff.newValue.nodeName = 'PRE';
|
||||||
}
|
}
|
||||||
@ -142,7 +148,7 @@ define([
|
|||||||
|
|
||||||
var removeForbiddenTags = function (root) {
|
var removeForbiddenTags = function (root) {
|
||||||
if (!root) { return; }
|
if (!root) { return; }
|
||||||
if (forbiddenTags.indexOf(root.nodeName) !== -1) { removeNode(root); }
|
if (forbiddenTags.indexOf(root.nodeName.toUpperCase()) !== -1) { removeNode(root); }
|
||||||
slice(root.children).forEach(removeForbiddenTags);
|
slice(root.children).forEach(removeForbiddenTags);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -143,7 +143,7 @@ define([
|
|||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
var $d = $(d);
|
var $d = $(d);
|
||||||
DiffMd.apply(DiffMd.render(md || ''), $d, common);
|
DiffMd.apply(DiffMd.render(md || '', true), $d, common);
|
||||||
$d.addClass("cp-app-contacts-content");
|
$d.addClass("cp-app-contacts-content");
|
||||||
|
|
||||||
// override link clicking, because we're in an iframe
|
// override link clicking, because we're in an iframe
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user