Correctly display HTML entities in event log (#4566)

This changes the event log to use a partial for the log message which double-encodes the data. When using formatted view in the log viewer widget, the HTML entites are allowed by decoding back a step. When in raw view, the HTML entities are kept double-encoded.

Fixes #4558.
This commit is contained in:
Ben Thomson 2019-12-17 22:43:44 +08:00 committed by GitHub
parent e19f20bcb7
commit a53cc52752
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 4 deletions

View File

@ -40,7 +40,7 @@
}
})
markup = self.parseSource(self.$el.text())
markup = self.parseSource(self.$el.html())
self.$el
.addClass('plugin-exception-beautifier')
@ -274,7 +274,10 @@
}
}
else {
markup += $.oc.escapeHtmlString(str)
// Allow HTML entities
str = str.replace(/&([^\s&;]+?);/g, '&$1;')
markup += str
.replace(/\{x-newline\}/g, '<br>')
.replace(/\{x-tabulation\}/g, '&nbsp;&nbsp;')
}
@ -353,7 +356,7 @@
tabs.find('#beautifier-tab-formatted').append(markup)
}
tabs.find('#beautifier-tab-raw').append('<div class="beautifier-raw-content">' + $.oc.escapeHtmlString(source.trim()).replace(/\r\n|\r|\n/g, '<br>').replace(/ {2}/g, '&nbsp;&nbsp;') + '</div>')
tabs.find('#beautifier-tab-raw').append('<div class="beautifier-raw-content">' + source.trim().replace(/\r\n|\r|\n/g, '<br>').replace(/ {2}/g, '&nbsp;&nbsp;') + '</div>')
tabs.ocTab({
closable: false

View File

@ -0,0 +1 @@
<?= e($value, true); ?>

View File

@ -5,6 +5,7 @@
fields:
message:
type: textarea
type: partial
path: field_message
containerAttributes:
data-plugin: exception-beautifier