@contentstack/cli-cm-export-to-csv 1.4.1 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/util/index.js +17 -1
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-cm-export-to-csv",
|
|
3
3
|
"description": "Export entities to csv",
|
|
4
|
-
"version": "1.4.
|
|
4
|
+
"version": "1.4.3",
|
|
5
5
|
"author": "Abhinav Gupta @abhinav-from-contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@contentstack/cli-command": "~1.2.
|
|
9
|
-
"@contentstack/cli-utilities": "~1.5.
|
|
8
|
+
"@contentstack/cli-command": "~1.2.13",
|
|
9
|
+
"@contentstack/cli-utilities": "~1.5.3",
|
|
10
10
|
"chalk": "^4.1.0",
|
|
11
11
|
"fast-csv": "^4.3.6",
|
|
12
12
|
"inquirer": "8.2.4",
|
package/src/util/index.js
CHANGED
|
@@ -371,6 +371,22 @@ function exitProgram() {
|
|
|
371
371
|
process.exit();
|
|
372
372
|
}
|
|
373
373
|
|
|
374
|
+
function sanitizeEntries(flatEntry) {
|
|
375
|
+
// sanitize against CSV Injections
|
|
376
|
+
const CSVRegex = /^[\\+\\=@\\-]/
|
|
377
|
+
for (key in flatEntry) {
|
|
378
|
+
if (typeof flatEntry[key] === 'string' && flatEntry[key].match(CSVRegex)) {
|
|
379
|
+
flatEntry[key] = flatEntry[key].replace(/\"/g, "\"\"");
|
|
380
|
+
flatEntry[key] = `"'${flatEntry[key]}"`
|
|
381
|
+
} else if (typeof flatEntry[key] === 'object') {
|
|
382
|
+
// convert any objects or arrays to string
|
|
383
|
+
// to store this data correctly in csv
|
|
384
|
+
flatEntry[key] = JSON.stringify(flatEntry[key]);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return flatEntry;
|
|
388
|
+
}
|
|
389
|
+
|
|
374
390
|
function cleanEntries(entries, language, environments, contentTypeUid) {
|
|
375
391
|
const filteredEntries = entries.filter((entry) => {
|
|
376
392
|
return entry['locale'] === language;
|
|
@@ -393,6 +409,7 @@ function cleanEntries(entries, language, environments, contentTypeUid) {
|
|
|
393
409
|
}
|
|
394
410
|
}
|
|
395
411
|
entry = flatten(entry);
|
|
412
|
+
entry = sanitizeEntries(entry);
|
|
396
413
|
entry['publish_details'] = envArr;
|
|
397
414
|
entry['_workflow'] = workflow;
|
|
398
415
|
entry['ACL'] = JSON.stringify({}); // setting ACL to empty obj
|
|
@@ -409,7 +426,6 @@ function cleanEntries(entries, language, environments, contentTypeUid) {
|
|
|
409
426
|
delete entry.publishRequest;
|
|
410
427
|
return entry;
|
|
411
428
|
});
|
|
412
|
-
console.log(filteredEntries.length);
|
|
413
429
|
}
|
|
414
430
|
|
|
415
431
|
function getDateTime() {
|