Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

html-uglify

Package Overview
Dependencies
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-uglify - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

22

lib/main.js
'use strict';
var postcss = require('postcss');
var cheerio = require('cheerio');
var Hashids = require('hashids');
var postcssSafeParser = require('postcss-safe-parser');

@@ -43,5 +43,5 @@ var ALPHABET = 'abcdefghijklmnopqrstuvwxyz';

default:
value;
break;
}
return this.whitelist.indexOf(value) >= 0;

@@ -121,6 +121,7 @@ };

var keyLookup = '';
var toReplace;
// handle #something
if (selectorPart.indexOf('#') > -1) {
var toReplace = selectorPart.replace(/\#/g, '');
toReplace = selectorPart.replace(/\#/g, '');
keyLookup = ['id', toReplace].join(LOOKUP_DELIMITER);

@@ -131,3 +132,3 @@ }

if (selectorPart.indexOf('.') > -1) {
var toReplace = selectorPart.replace(/\./g, '');
toReplace = selectorPart.replace(/\./g, '');
keyLookup = ['class', toReplace].join(LOOKUP_DELIMITER);

@@ -138,4 +139,3 @@ }

if (selectorPart.indexOf('id=') > -1){
var toReplace = selectorPart.replace(/id=/g, '');
toReplace = toReplace.replace(/\"/g, ''); // remove quotes from "somevalue"
toReplace = selectorPart.replace(/id=/g, '').replace(/\"/g, ''); // remove quotes from "somevalue"
keyLookup = ['id', toReplace].join(LOOKUP_DELIMITER);

@@ -146,3 +146,3 @@ }

if (selectorPart.indexOf('class=') > -1) {
var toReplace = selectorPart.replace(/class=/g, '');
toReplace = selectorPart.replace(/class=/g, '');
keyLookup = ['class', toReplace].join(LOOKUP_DELIMITER);

@@ -153,3 +153,3 @@ }

if (selectorPart.indexOf('for=') > -1){
var toReplace = selectorPart.replace(/for=/g, '');
toReplace = selectorPart.replace(/for=/g, '');
toReplace = toReplace.replace(/\"/g, ''); // remove quotes from "somevalue"

@@ -176,5 +176,5 @@ keyLookup = ['id', toReplace].join(LOOKUP_DELIMITER);

$('style').each(function(index, element) {
$('style').each(function() {
var $style = $(this);
var ast = postcss.parse($style.text(), { safe: true });
var ast = postcssSafeParser($style.text());
_this.processRules(ast.nodes, lookups);

@@ -181,0 +181,0 @@ $style.text(ast.toString());

{
"name": "html-uglify",
"version": "1.1.2",
"version": "1.1.3",
"description": "Uglifies an HTML file and its associated CSS for compression. Great for HTML emails!",

@@ -22,7 +22,7 @@ "main": "lib/main.js",

"hashids": "^1.0.2",
"postcss": "^4.1.16"
"postcss-safe-parser": "^1.0.1"
},
"devDependencies": {
"chai": "^3.2.0",
"mocha": "^2.2.5"
"chai": "^3.4.1",
"mocha": "^2.3.4"
},

@@ -29,0 +29,0 @@ "repository": {

@@ -15,3 +15,3 @@ 'use strict';

beforeEach(function() {
whitelist = ['#theid', '.theclass'];
whitelist = ['#theid', '.theclass', '#★', '.★'];
htmlUglify = new HTMLUglify({whitelist: whitelist});

@@ -31,2 +31,10 @@ });

});
it('returns true if id is in whitelist for a unicode character', function() {
var whitelisted = htmlUglify.isWhitelisted('id', '★')
assert.isTrue(whitelisted);
});
it('returns true if class is in whitelist for a unicode character', function() {
var whitelisted = htmlUglify.isWhitelisted('class', '★')
assert.isTrue(whitelisted);
});
});

@@ -33,0 +41,0 @@ describe('#rewriteStyles', function() {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc