-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DoS vulnerability via obsolete "css-what" version #104
Comments
I recently upgraded css-what for a project that I am working on. Part of the fix included forcing the resolution of cheerio to 1.0.0.rc-10. However, this version of cheerio seems to be incompatible with the current version of inline-css, now the following error always appears when requiring inline-css: Which comes from the (attempted) change on the prototype change to cheerio in this file: https://github.com/jonkemp/inline-css/blob/4291cdf1ffbeddd6c11e963b5b3b5f6e35d5f4ae/lib/setTableAttrs.js Is it possible achieve the same behavior without prototype modification? For more info: let inline = require("inline-css"); |
diff --git a/lib/setTableAttrs.js b/lib/setTableAttrs.js
index 144056d..656191c 100644
--- a/lib/setTableAttrs.js
+++ b/lib/setTableAttrs.js
@@ -1,5 +1,3 @@
-const cheerio = require('cheerio');
-
const tableStyleAttrMap = {
table: {
float: 'align',
@@ -53,20 +51,13 @@ const batchApplyStylesAsProps = ($el, sel, $) => {
});
};
-cheerio.prototype.resetAttr = function (attribute) {
- if (!this.attr(attribute)) {
- this.attr(attribute, 0);
- }
- return this;
-};
-
module.exports = (el, $) => {
let selector;
let $el = $(el);
- $el = $el.resetAttr('border')
- .resetAttr('cellpadding')
- .resetAttr('cellspacing');
+ [ 'border', 'cellpadding', 'cellspacing' ]
+ .filter((attribute) => !$el.attr(attribute))
+ .forEach((attribute) => $el.attr(attribute, 0));
for (selector in tableStyleAttrMap) {
if (selector === 'table') { This should work with recent cheerio versions too. Unfortunately the HTML output changed and a lot of tests fail now. Maybe it makes sense to pipe results through a beautifier or use something like chai-html. @jonkemp: What do you think about necessary changes? |
Hello Maintainers,
I want to get this on your radar:
npm audit
is failing for vulnerability incss-what
packageI saw cheerio is working on fixing it here and looking forward for
inline-css
to incorporate this update and resolve vulnerabilityThe text was updated successfully, but these errors were encountered: