From 3a6d065e503def8e9ca47dd6780b9ddbc0772509 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Mon, 1 Feb 2016 16:54:27 +0100 Subject: [PATCH] Fix formatting messages with newlines --- apps/comments/js/commentstabview.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js index c2fa08ed20..bc496f2e59 100644 --- a/apps/comments/js/commentstabview.js +++ b/apps/comments/js/commentstabview.js @@ -38,7 +38,7 @@ '
{{actorDisplayName}}
' + '
{{date}}
' + ' ' + - '
{{message}}
' + + '
{{{formattedMessage}}}
' + ''; /** @@ -122,7 +122,8 @@ var timestamp = new Date(commentModel.get('creationDateTime')).getTime(); var data = _.extend({ date: OC.Util.relativeModifiedDate(timestamp), - altDate: OC.Util.formatDate(timestamp) + altDate: OC.Util.formatDate(timestamp), + formattedMessage: this._formatMessage(commentModel.get('message')) }, commentModel.attributes); // TODO: format return data; @@ -165,6 +166,14 @@ } }, + /** + * Convert a message to be displayed in HTML, + * converts newlines to
tags. + */ + _formatMessage: function(message) { + return escapeHTML(message).replace(/\n/g, '
'); + }, + nextPage: function() { if (this._loading || !this.collection.hasMoreResults()) { return;