From 5c2d616e0c5fa2a334c8defe46389753ef7b180b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs?= Date: Sat, 21 Sep 2019 16:09:13 -0500 Subject: Improve filter and syntax --- js/i18n.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/js/i18n.js b/js/i18n.js index da7d469..3a6b0e2 100644 --- a/js/i18n.js +++ b/js/i18n.js @@ -43,12 +43,10 @@ // used to check the source text. The above comment is kept just // in case. - let reSafeTags = - /^([\s\S]*?)<(b|blockquote|code|em|i|kbd|span|sup)>(.+?)<\/\2>([\s\S]*)$/; + let reSafeTags = /^([\s\S]*?)<(b|blockquote|code|em|i|kbd|span|sup)>(.+?)<\/\2>([\s\S]*)$/; let reSafeInput = /^([\s\S]*?)<(input type="[^"]+")>(.*?)([\s\S]*)$/; let reInput = /^input type=(['"])([a-z]+)\1$/; - let reSafeLink = - /^([\s\S]*?)<(a href=['"]https?:\/\/[^'" <>]+['"])>(.+?)<\/a>([\s\S]*)$/; + let reSafeLink = /^([\s\S]*?)<(a href=['"]https?:\/\/[^'" <>]+['"])>(.+?)<\/a>([\s\S]*)$/; let reLink = /^a href=(['"])(https?:\/\/[^'"]+)\1$/; var safeTextToTagNode = function(text) { @@ -106,7 +104,8 @@ .replace(/‘/g, '‘') .replace(/’/g, '’') .replace(/</g, '<') - .replace(/>/g, '>'); + .replace(/>/g, '>') + .replace(/'/g, '\''); } return document.createTextNode(text); }; -- cgit v1.2.3