From b59952e12e2f0fe1782d894fd4a6edb2f2327a43 Mon Sep 17 00:00:00 2001 From: "ZUO, JACOB [ITUIS]" Date: Thu, 9 Jan 2020 13:28:22 -0600 Subject: [PATCH 1/3] fixing exceptions when attribute contains no value --- src/htmlminifier.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/htmlminifier.js b/src/htmlminifier.js index d7efa991..6aac94f2 100644 --- a/src/htmlminifier.js +++ b/src/htmlminifier.js @@ -182,7 +182,12 @@ function isExecutableScript(tag, attrs) { } function isStyleLinkTypeAttribute(attrValue) { - attrValue = trimWhitespace(attrValue).toLowerCase(); + attrValue = trimWhitespace(attrValue); + if (!attrValue) { + return true; + } + + attrValue = attrValue.toLowerCase(); return attrValue === '' || attrValue === 'text/css'; } From c9497088d7f537d41acb6ad7097536695a34fd7f Mon Sep 17 00:00:00 2001 From: "ZUO, JACOB [ITUIS]" Date: Thu, 9 Jan 2020 13:36:22 -0600 Subject: [PATCH 2/3] handling other illegal entries as well --- src/htmlminifier.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/htmlminifier.js b/src/htmlminifier.js index 6aac94f2..89d279a8 100644 --- a/src/htmlminifier.js +++ b/src/htmlminifier.js @@ -183,11 +183,13 @@ function isExecutableScript(tag, attrs) { function isStyleLinkTypeAttribute(attrValue) { attrValue = trimWhitespace(attrValue); - if (!attrValue) { - return true; + + if (typeof attrValue !== 'string') { + attrValue = ''; + } else { + attrValue = attrValue.toLowerCase(); } - attrValue = attrValue.toLowerCase(); return attrValue === '' || attrValue === 'text/css'; } From eaacd0e1f60b130998e323db672ba22fbacc3914 Mon Sep 17 00:00:00 2001 From: Jacob Zuo Date: Mon, 3 Feb 2020 16:04:13 -0600 Subject: [PATCH 3/3] only handle exceptions with 'undefined' values reverting from a more sweeping change where any attrValue not of the type of 'string' is treated as a blank entry. --- src/htmlminifier.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/htmlminifier.js b/src/htmlminifier.js index 89d279a8..c4d373bd 100644 --- a/src/htmlminifier.js +++ b/src/htmlminifier.js @@ -184,7 +184,7 @@ function isExecutableScript(tag, attrs) { function isStyleLinkTypeAttribute(attrValue) { attrValue = trimWhitespace(attrValue); - if (typeof attrValue !== 'string') { + if (typeof attrValue === 'undefined') { attrValue = ''; } else { attrValue = attrValue.toLowerCase();