Permalink
Browse files

Strip trailing ";" from event attributes (onclick, onmouseover, etc.).

  • Loading branch information...
kangax committed Mar 15, 2010
1 parent 6c7e4eb commit e753a32b92c1acd27c40f1bcb459dba4f53b03f6
Showing with 4 additions and 4 deletions.
  1. +1 −1 src/htmlminifier.js
  2. +3 −3 tests/index.html
View
@@ -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));
View
@@ -295,11 +295,11 @@ <h2 id="qunit-userAgent"></h2>
});
test('cleaning other attributes', function() {
- input = '<a href="#" onclick=" window.prompt(\'boo\'); " onmouseover=" \n\n alert(123); \t \n\t ">blah</a>';
- output = '<a href="#" onclick="window.prompt(\'boo\');" onmouseover="alert(123);">blah</a>';
+ input = '<a href="#" onclick=" window.prompt(\'boo\'); " onmouseover=" \n\n alert(123) \t \n\t ">blah</a>';
+ output = '<a href="#" onclick="window.prompt(\'boo\')" onmouseover="alert(123)">blah</a>';
equals(minify(input, { cleanAttributes: true }), output);
- input = '<body onload=" foo(); bar() "><p>x</body>';
+ input = '<body onload=" foo(); bar() ; "><p>x</body>';
output = '<body onload="foo(); bar()"><p>x</p></body>';
equals(minify(input, { cleanAttributes: true }), output);
});

0 comments on commit e753a32

Please sign in to comment.