Use DiffMarked in messenger to avoid duplicate code

pull/1/head
yflory 6 years ago
parent dcdc0972dd
commit fc915e3337

@ -101,8 +101,8 @@ define([
'IFRAME', 'IFRAME',
'OBJECT', 'OBJECT',
'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
]; ];
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) {

@ -4,9 +4,8 @@ define([
'/common/common-util.js', '/common/common-util.js',
'/common/common-interface.js', '/common/common-interface.js',
'/common/hyperscript.js', '/common/hyperscript.js',
'/bower_components/marked/marked.min.js', '/common/diffMarked.js',
'/common/media-tag.js', ], function ($, Messages, Util, UI, h, DiffMd) {
], function ($, Messages, Util, UI, h, Marked, MediaTag) {
'use strict'; 'use strict';
var debug = console.log; var debug = console.log;
@ -138,12 +137,14 @@ define([
$(window).on('resize', onResize); $(window).on('resize', onResize);
var m = function (md, hour) { var m = function (md, hour) {
var d = h('div.cp-app-contacts-content'); var id = Util.createRandomInteger();
var d = h('div', {
id: 'msg-'+id
});
try { try {
d.innerHTML = Marked(md || '');
var $d = $(d); var $d = $(d);
// remove potentially malicious elements DiffMd.apply(DiffMd.render(md || ''), $d, common);
$d.find('script, iframe, object, applet, video, audio').remove(); $d.addClass("cp-app-contacts-content");
// override link clicking, because we're in an iframe // override link clicking, because we're in an iframe
$d.find('a').each(function () { $d.find('a').each(function () {
@ -153,9 +154,6 @@ define([
}).attr('href'); }).attr('href');
}); });
// activate media-tags
$d.find('media-tag').each(function (i, e) { MediaTag(e); });
var time = h('div.cp-app-contacts-time', hour); var time = h('div.cp-app-contacts-time', hour);
$d.append(time); $d.append(time);
} catch (e) { } catch (e) {

Loading…
Cancel
Save