diff --git a/IPython/frontend/html/notebook/static/js/codecell.js b/IPython/frontend/html/notebook/static/js/codecell.js index 971a1c9..7bcd57a 100644 --- a/IPython/frontend/html/notebook/static/js/codecell.js +++ b/IPython/frontend/html/notebook/static/js/codecell.js @@ -598,7 +598,9 @@ var IPython = (function (IPython) { if (last.output_type == 'stream' && json.stream == last.stream){ // latest output was in the same stream, // so append directly into its pre tag - this.element.find('div.'+subclass).last().find('pre').append(json.text); + // escape ANSI & HTML specials: + var text = utils.fixConsole(json.text); + this.element.find('div.'+subclass).last().find('pre').append(text); return; } } @@ -647,6 +649,8 @@ var IPython = (function (IPython) { CodeCell.prototype.append_text = function (data, element, extra_class) { var toinsert = $("<div/>").addClass("box_flex1 output_subarea output_text"); + // escape ANSI & HTML specials in plaintext: + data = utils.fixConsole(data); if (extra_class){ toinsert.addClass(extra_class); } diff --git a/IPython/frontend/html/notebook/static/js/notebook.js b/IPython/frontend/html/notebook/static/js/notebook.js index f4af97a..4750ea1 100644 --- a/IPython/frontend/html/notebook/static/js/notebook.js +++ b/IPython/frontend/html/notebook/static/js/notebook.js @@ -816,7 +816,7 @@ var IPython = (function (IPython) { var json = {}; json.output_type = msg_type; if (msg_type === "stream") { - json.text = utils.fixConsole(content.data); + json.text = content.data; json.stream = content.name; } else if (msg_type === "display_data") { json = this.convert_mime_types(json, content.data); @@ -826,11 +826,7 @@ var IPython = (function (IPython) { } else if (msg_type === "pyerr") { json.ename = content.ename; json.evalue = content.evalue; - var traceback = []; - for (var i=0; i<content.traceback.length; i++) { - traceback.push(utils.fixConsole(content.traceback[i])); - } - json.traceback = traceback; + json.traceback = content.traceback; }; cell.append_output(json); this.dirty = true; @@ -839,7 +835,7 @@ var IPython = (function (IPython) { Notebook.prototype.convert_mime_types = function (json, data) { if (data['text/plain'] !== undefined) { - json.text = utils.fixConsole(data['text/plain']); + json.text = data['text/plain']; }; if (data['text/html'] !== undefined) { json.html = data['text/html'];