Encode html entities in log

This commit is contained in:
Ruud committed 2012-06-30 19:58:53 +02:00
1 parent 0fc5c42aba
commit 3b441d2942
1 file changed
+10 -9
+10 -9
View File
@@ -78,15 +78,16 @@ Page.Log = new Class({
addColors: function(text){ addColors: function(text){
var self = this; var self = this;
var text = new Element('div', { text = text
'html': text .replace(/&/g, '&')
}).get('text') .replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
text = text.replace(/\u001b\[31m/gi, '</span><span class="error">') .replace(/"/g, '&quot;')
text = text.replace(/\u001b\[36m/gi, '</span><span class="debug">') .replace(/\u001b\[31m/gi, '</span><span class="error">')
text = text.replace(/\u001b\[33m/gi, '</span><span class="debug">') .replace(/\u001b\[36m/gi, '</span><span class="debug">')
text = text.replace(/\u001b\[0m\n/gi, '</span><span class="time">') .replace(/\u001b\[33m/gi, '</span><span class="debug">')
text = text.replace(/\u001b\[0m/gi, '</span><span>') .replace(/\u001b\[0m\n/gi, '</span><span class="time">')
.replace(/\u001b\[0m/gi, '</span><span>')
return '<span class="time">' + text + '</span>'; return '<span class="time">' + text + '</span>';
} }