Preserve quotes if attribute ends with a trailing slash
authorstieler-it <michael@stieler.it>
Tue, 22 Oct 2013 09:56:53 +0000 (11:56 +0200)
committerstieler-it <michael@stieler.it>
Tue, 22 Oct 2013 09:56:53 +0000 (11:56 +0200)
minified URLs in parameters, like <a href="http://www.example.com/"> need to keept their quotes because <a href=http://www.example.com/> is interpreted as an URL without trailing slash

src/htmlminifier.js

index d07f221..e5b2c21 100644 (file)
@@ -76,7 +76,7 @@
 
   function canRemoveAttributeQuotes(value) {
     // http://mathiasbynens.be/notes/unquoted-attribute-values
-    return (/^[^\x20\t\n\f\r"'`=<>]+$/).test(value);
+    return (/^[^\x20\t\n\f\r"'`=<>]+$/).test(value) && !(/\/$/ ).test(value);
   }
 
   function attributesInclude(attributes, attribute) {