From: Juriy Zaytsev Date: Mon, 15 Mar 2010 18:01:43 +0000 (-0400) Subject: Strip trailing ";" from event attributes (onclick, onmouseover, etc.). X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=e753a32b92c1acd27c40f1bcb459dba4f53b03f6;p=html-minifier.git Strip trailing ";" from event attributes (onclick, onmouseover, etc.). --- diff --git a/src/htmlminifier.js b/src/htmlminifier.js index e42e2db..031b617 100644 --- a/src/htmlminifier.js +++ b/src/htmlminifier.js @@ -118,7 +118,7 @@ function cleanAttributeValue(tag, attrName, attrValue) { if (isEventAttribute(attrName)) { - return trimWhitespace(attrValue).replace(/^javascript:\s*/i, ''); + return trimWhitespace(attrValue).replace(/^javascript:\s*/i, '').replace(/\s*;$/, ''); } else if (attrName === 'class') { return collapseWhitespace(trimWhitespace(attrValue)); diff --git a/tests/index.html b/tests/index.html index bec13dc..818f492 100644 --- a/tests/index.html +++ b/tests/index.html @@ -295,11 +295,11 @@ }); test('cleaning other attributes', function() { - input = 'blah'; - output = 'blah'; + input = 'blah'; + output = 'blah'; equals(minify(input, { cleanAttributes: true }), output); - input = '

x'; + input = '

x'; output = '

x

'; equals(minify(input, { cleanAttributes: true }), output); });