diff --git a/node/utils/ExportHtml.js b/node/utils/ExportHtml.js index 46ed980a5..c699c4119 100644 --- a/node/utils/ExportHtml.js +++ b/node/utils/ExportHtml.js @@ -292,7 +292,7 @@ function getHTMLFromAtext(pad, atext) var url = urlData[1]; var urlLength = url.length; processNextChars(startIndex - idx); - assem.append(''); + assem.append(''); processNextChars(urlLength); assem.append(''); }); @@ -429,14 +429,15 @@ exports.getPadHTMLDocument = function (padId, revNum, noDocType, callback) function _escapeHTML(s) { - var re = /[&<>]/g; + var re = /[&"<>]/g; if (!re.MAP) { // persisted across function calls! re.MAP = { '&': '&', + '"': '"', '<': '<', - '>': '>', + '>': '>' }; } diff --git a/static/js/ace2_common.js b/static/js/ace2_common.js index 1246a16ec..1e5c415c7 100644 --- a/static/js/ace2_common.js +++ b/static/js/ace2_common.js @@ -142,7 +142,14 @@ function binarySearchInfinite(expectedLength, func) function htmlPrettyEscape(str) { - return str.replace(/&/g, '&').replace(//g, '>').replace(/\r?\n/g, '\\n'); + return str.replace(/[&"<>]/g, function (c) { + return { + '&': '&', + '"': '"', + '<': '<', + '>': '>' + }[c] || c; + }).replace(/\r?\n/g, '\\n'); } if (typeof exports !== "undefined") diff --git a/static/js/domline.js b/static/js/domline.js index 56f74a1cd..3456419c4 100644 --- a/static/js/domline.js +++ b/static/js/domline.js @@ -162,7 +162,7 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument) { href = "http://"+href; } - extraOpenTags = extraOpenTags + ''; + extraOpenTags = extraOpenTags + ''; extraCloseTags = '' + extraCloseTags; } if (simpleTags) @@ -229,7 +229,7 @@ domline.escapeHTML = function(s) '&': '&', '<': '<', '>': '>', - '"': '"', + '"': '"', "'": ''' }; } diff --git a/static/js/domline_client.js b/static/js/domline_client.js index a152412c9..cac753b96 100644 --- a/static/js/domline_client.js +++ b/static/js/domline_client.js @@ -158,7 +158,7 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument) { if (href) { - extraOpenTags = extraOpenTags + ''; + extraOpenTags = extraOpenTags + ''; extraCloseTags = '' + extraCloseTags; } if (simpleTags) diff --git a/static/js/pad_utils.js b/static/js/pad_utils.js index 76a167057..9083fa9b6 100644 --- a/static/js/pad_utils.js +++ b/static/js/pad_utils.js @@ -23,7 +23,14 @@ var padutils = { escapeHtml: function(x) { - return String(x).replace(/\/g, '>'); + return String(x).replace(/[&"<>]/g, function (c) { + return { + '&': '&', + '"': '"', + '<': '<', + '>': '>' + }[c] || c; + }); }, uniqueId: function() { @@ -180,7 +187,7 @@ var padutils = { var startIndex = urls[j][0]; var href = urls[j][1]; advanceTo(startIndex); - pieces.push(''); + pieces.push(''); advanceTo(startIndex + href.length); pieces.push(''); }