From 1516807ed548d95e031f4ff64506764fd9c50e5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Vi=E1=BB=87t=20H=C6=B0ng?= Date: Sun, 20 May 2018 19:24:36 +0700 Subject: [PATCH] fixed double escape html --- browser/lib/utils.js | 43 ++++++------------------------------------- 1 file changed, 6 insertions(+), 37 deletions(-) diff --git a/browser/lib/utils.js b/browser/lib/utils.js index f67ca377..d27449e0 100644 --- a/browser/lib/utils.js +++ b/browser/lib/utils.js @@ -15,43 +15,12 @@ export function escapeHtmlCharacters (text) { return str } - let escape - let html = '' - let index = 0 - let lastIndex = 0 - - for (index = match.index; index < str.length; index++) { - switch (str.charCodeAt(index)) { - case 34: // " - escape = '"' - break - case 38: // & - escape = '&' - break - case 39: // ' - escape = ''' - break - case 60: // < - escape = '<' - break - case 62: // > - escape = '>' - break - default: - continue - } - - if (lastIndex !== index) { - html += str.substring(lastIndex, index) - } - - lastIndex = index + 1 - html += escape - } - - return lastIndex !== index - ? html + str.substring(lastIndex, index) - : html + return str + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, ''') } export default {