From f031af4e9dd350be2aa61bab387436aa58669634 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 25 Oct 2017 10:50:17 +0200 Subject: [PATCH] fix broken media-tags in contacts --- www/contacts/messenger-ui.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/www/contacts/messenger-ui.js b/www/contacts/messenger-ui.js index fddad4497..b5c2f0c06 100644 --- a/www/contacts/messenger-ui.js +++ b/www/contacts/messenger-ui.js @@ -3,10 +3,9 @@ define([ '/common/cryptpad-common.js', '/common/hyperscript.js', '/bower_components/marked/marked.min.js', -], function ($, Cryptpad, h, Marked) { + '/common/media-tag.js', +], function ($, Cryptpad, h, Marked, MediaTag) { 'use strict'; - // TODO use our fancy markdown and support media-tags - Marked.setOptions({ sanitize: true, }); var UI = {}; var Messages = Cryptpad.Messages; @@ -15,6 +14,12 @@ define([ var d = h('div.cp-app-contacts-content'); try { d.innerHTML = Marked(md || ''); + var $d = $(d); + // remove potentially malicious elements + $d.find('script, iframe, object, applet, video, audio').remove(); + + // activate media-tags + $d.find('media-tag').each(function (i, e) { MediaTag(e); }); } catch (e) { console.error(md); console.error(e);