]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix formatting messages with newlines
authorVincent Petry <pvince81@owncloud.com>
Mon, 1 Feb 2016 15:54:27 +0000 (16:54 +0100)
committerVincent Petry <pvince81@owncloud.com>
Tue, 2 Feb 2016 17:01:15 +0000 (18:01 +0100)
apps/comments/js/commentstabview.js

index c2fa08ed20e8d7f4d16e6dede684517cae333af9..bc496f2e599b5e8925df09b0ce394fe7c3ef24f7 100644 (file)
@@ -38,7 +38,7 @@
                '        <div class="author">{{actorDisplayName}}</div>' +
                '        <div class="date has-tooltip" title="{{altDate}}">{{date}}</div>' +
                '    </div>' +
-               '    <div class="message">{{message}}</div>' +
+               '    <div class="message">{{{formattedMessage}}}</div>' +
                '</li>';
 
        /**
                        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;
                        }
                },
 
+               /**
+                * Convert a message to be displayed in HTML,
+                * converts newlines to <br> tags.
+                */
+               _formatMessage: function(message) {
+                       return escapeHTML(message).replace(/\n/g, '<br/>');
+               },
+
                nextPage: function() {
                        if (this._loading || !this.collection.hasMoreResults()) {
                                return;