mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-13 12:15:10 +00:00
Merge pull request #398 from kazuki-hanai/escape-html
Fix: Add HTML escaping to dashboard log messages
This commit is contained in:
1 file changed
+16
@@ -1,5 +1,6 @@
|
||||
class LogMessage {
|
||||
constructor(message, toolNames) {
|
||||
message = this.escapeHtml(message);
|
||||
const logLevel = this.determineLogLevel(message);
|
||||
const highlightedMessage = this.highlightToolNames(message, toolNames);
|
||||
this.$elem = $('<div>').addClass('log-' + logLevel).html(highlightedMessage + '\n');
|
||||
@@ -27,6 +28,21 @@ class LogMessage {
|
||||
});
|
||||
return highlightedMessage;
|
||||
}
|
||||
|
||||
escapeHtml (convertString) {
|
||||
if (typeof convertString !== 'string') return convertString;
|
||||
|
||||
const patterns = {
|
||||
'<' : '<',
|
||||
'>' : '>',
|
||||
'&' : '&',
|
||||
'"' : '"',
|
||||
'\'' : ''',
|
||||
'`' : '`'
|
||||
};
|
||||
|
||||
return convertString.replace(/[<>&"'`]/g, match => patterns[match]);
|
||||
};
|
||||
}
|
||||
|
||||
class Dashboard {
|
||||
|
||||
Reference in new issue
Block a user