Skip to content
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

Update mjml to v5-alpha and gulp to v5 to fix vulnerability CVE-2022-37620 #77

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gulp-mjml",
"version": "4.0.2",
"version": "5.0.0-alpha",
"description": "Add Gulp to your MJML workflow",
"main": "src/index",
"scripts": {
Expand All @@ -12,13 +12,13 @@
],
"license": "MIT",
"dependencies": {
"mjml": "^4.0.0",
"mjml": "^5.0.0-alpha.4",
"plugin-error": "^1.0.1",
"replace-ext": "^1.0.0",
"through2": "^3.0.1"
},
"devDependencies": {
"gulp": "^4.0.0"
"gulp": "^5.0.0"
},
"repository": {
"type": "git",
Expand Down
28 changes: 15 additions & 13 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ module.exports = function mjml(mjmlEngine, options) {
}

return through.obj(function(file, enc, callback) {
const that = this;

// Not a big fan of this deep copy methods
// But it will work regardless of Node version
const localOptions = JSON.parse(JSON.stringify(options));
Expand All @@ -36,19 +38,19 @@ module.exports = function mjml(mjmlEngine, options) {

if (file.isBuffer()) {
const output = file.clone();
let render;

try {
render = mjmlEngine(file.contents.toString(), localOptions);
} catch (e) {
this.emit("error", raise(e.message));
return callback();
}

// [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues
output.contents = Buffer.from(render.html);
output.path = replaceExt(file.path.toString(), localOptions.fileExt || ".html");
this.push(output);

return mjmlEngine(file.contents.toString(), localOptions)
.then(function (render) {
// [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues
output.contents = Buffer.from(render.html);
output.path = replaceExt(file.path.toString(), localOptions.fileExt || ".html");
that.push(output);
})
.catch(function (error) {
that.emit("error", raise(error));
return callback();
})
.then(callback);
}
return callback();
});
Expand Down
Loading