From 4e69174c51268b2b0ed6395683b91bb87488f050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Kr=C3=A4ftner?= Date: Fri, 4 Nov 2016 15:24:20 +0100 Subject: [PATCH] Update Regex to handle DTD markup declarations (#9) * Update Regex to handle DTD markup declarations Fixes #8 * Add test for DTD markup declaration --- index.js | 2 +- test.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index d7b6f90..1b6da1a 100644 --- a/index.js +++ b/index.js @@ -16,5 +16,5 @@ function isBinary(buf) { } module.exports = function (buf) { - return !isBinary(buf) && /^\s*(?:<\?xml[^>]*>\s*)?(?:]*>\s*)?]*>[^]*<\/svg>\s*$/i.test(buf.toString().replace(htmlCommentRegex, '')); + return !isBinary(buf) && /^\s*(?:<\?xml[^>]*>\s*)?(?:]*\s*(?:]*>)*[^>]*>\s*)?]*>[^]*<\/svg>\s*$/i.test(buf.toString().replace(htmlCommentRegex, '')); }; diff --git a/test.js b/test.js index 2b56837..a5bcc38 100644 --- a/test.js +++ b/test.js @@ -7,6 +7,7 @@ test('valid SVGs', t => { t.true(m('')); t.true(m('')); t.true(m('\n\n')); + t.true(m(']>')); t.true(m(' ')); t.true(m(' ')); t.true(m('\n'));