Skip to content
This repository has been archived by the owner on May 16, 2019. It is now read-only.

Commit

Permalink
Merge pull request #1804 from OpenBazaar/allowHrefInAnchorInChat
Browse files Browse the repository at this point in the history
Adds the same sanitizer settings to chat as used in the medium editor…
  • Loading branch information
rmisio authored Oct 10, 2016
2 parents 625c00f + 7d09bb3 commit eeb01cd
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions js/views/chatMessageVw.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
var __ = require('underscore'),
$ = require('jquery'),
moment = require('moment'),
sanitizeHTML = require('sanitize-html'),
loadTemplate = require('../utils/loadTemplate'),
app = require('../App.js').getApp(),
baseVw = require('./baseVw');
Expand All @@ -29,14 +28,11 @@ module.exports = baseVw.extend({

render: function(){
var sanitizedMsg,
msgTxt = this.model.get('message'),
$msg;

sanitizedMsg = sanitizeHTML(this.model.get('message').replace(/\n$/, '').split(/[\r\n]/g).join('<br/><br/>'), {
allowedTags: [ 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'a', 'u', 'ul', 'ol', 'nl', 'li', 'b', 'i', 'strong', 'em', 'strike', 'hr', 'br', 'img' ]
});

// add js-externalLink class to any links in the message text
$msg = $('<div>' + sanitizedMsg + '</div>');
$msg = $('<div>' + msgTxt + '</div>');
$msg.find('a').addClass('js-externalLink');
sanitizedMsg = $msg.html();

Expand All @@ -52,7 +48,7 @@ module.exports = baseVw.extend({
)
);
});

return this;
}
});
});

0 comments on commit eeb01cd

Please sign in to comment.