From e753a32b92c1acd27c40f1bcb459dba4f53b03f6 Mon Sep 17 00:00:00 2001 From: Juriy Zaytsev Date: Mon, 15 Mar 2010 14:01:43 -0400 Subject: [PATCH] Strip trailing ";" from event attributes (onclick, onmouseover, etc.). --- src/htmlminifier.js | 2 +- tests/index.html | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) 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); }); -- 2.34.1