Socket
Socket
Sign inDemoInstall

mjml-parser-xml

Package Overview
Dependencies
4
Maintainers
6
Versions
67
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.8.2 to 4.9.0

84

lib/index.js

@@ -78,2 +78,3 @@ "use strict";

let inEndingTag = 0;
const cssIncludes = [];
const currentEndingTagIndexes = {

@@ -90,2 +91,58 @@ startIndex: 0,

const handleCssHtmlInclude = (file, attrs, line) => {
const partialPath = _path.default.resolve(cwd, file);
let content;
try {
content = _fs.default.readFileSync(partialPath, 'utf8');
} catch (e) {
const newNode = {
line,
file,
absoluteFilePath: _path.default.resolve(cwd, actualPath),
parent: cur,
tagName: 'mj-raw',
content: `<!-- mj-include fails to read file : ${file} at ${partialPath} -->`,
children: [],
errors: [{
type: 'include',
params: {
file,
partialPath
}
}]
};
cur.children.push(newNode);
return;
}
if (attrs.type === 'html') {
const newNode = {
line,
file,
absoluteFilePath: _path.default.resolve(cwd, actualPath),
parent: cur,
tagName: 'mj-raw',
content
};
cur.children.push(newNode);
return;
}
const attributes = attrs['css-inline'] === 'inline' ? {
inline: 'inline'
} : {};
const newNode = {
line,
file,
absoluteFilePath: _path.default.resolve(cwd, actualPath),
tagName: 'mj-style',
content,
children: [],
attributes
};
cssIncludes.push(newNode);
};
const handleInclude = (file, line) => {

@@ -194,2 +251,8 @@ const partialPath = _path.default.resolve(cwd, file);

if (ignoreIncludes || !isNode) return;
if (attrs.type === 'css' || attrs.type === 'html') {
handleCssHtmlInclude(decodeURIComponent(attrs.path), attrs, line);
return;
}
inInclude = true;

@@ -289,2 +352,23 @@ handleInclude(decodeURIComponent(attrs.path), line);

if (cssIncludes.length) {
const head = (0, _find2.default)(mjml.children, {
tagName: 'mj-head'
});
if (head) {
if (head.children) {
head.children = [...head.children, ...cssIncludes];
} else {
head.children = cssIncludes;
}
} else {
mjml.children.push({
file: filePath,
line: 0,
tagName: 'mj-head',
children: cssIncludes
});
}
}
return mjml;

@@ -291,0 +375,0 @@ }

8

package.json
{
"name": "mjml-parser-xml",
"description": "mjml-parser-xml",
"version": "4.8.2",
"version": "4.9.0",
"main": "lib/index.js",

@@ -33,7 +33,7 @@ "files": [

"chai": "^4.1.1",
"mjml": "4.8.2",
"mjml-core": "4.8.2",
"mjml": "4.9.0",
"mjml-core": "4.9.0",
"rimraf": "^3.0.2"
},
"gitHead": "67cb33b5edd2b1d80436a72c213d2e815a685cd5"
"gitHead": "167a375d47aa78e834376b99c8a2bbbc0c3581a0"
}
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc