Skip to content

Commit f459b80

Browse files
committed
Updated sanitizePath Regex
1 parent cc3f398 commit f459b80

File tree

12 files changed

+52
-48
lines changed

12 files changed

+52
-48
lines changed

package-lock.json

Lines changed: 22 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/contentstack-export/src/commands/cm/stacks/export.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import path from 'path';
22
import { Command } from '@contentstack/cli-command';
33
import {
4-
cliux,
54
messageHandler,
65
printFlagDeprecation,
76
managementSDKClient,
87
flags,
98
ContentstackClient,
109
FlagInput,
1110
pathValidator,
11+
sanitizePath,
1212
} from '@contentstack/cli-utilities';
1313
import { ModuleExporter } from '../../../export';
1414
import { setupExportConfig, log, formatError, writeExportMetaFile } from '../../../utils';
@@ -108,7 +108,7 @@ export default class ExportCommand extends Command {
108108
exportConfig.region = this.region;
109109
exportConfig.developerHubBaseUrl = this.developerHubUrl;
110110
if (this.personalizeUrl) exportConfig.modules.personalize.baseURL[exportConfig.region.name] = this.personalizeUrl;
111-
exportDir = exportConfig.cliLogsPath || exportConfig.data || exportConfig.exportDir;
111+
exportDir = sanitizePath(exportConfig.cliLogsPath || exportConfig.data || exportConfig.exportDir);
112112
const managementAPIClient: ContentstackClient = await managementSDKClient(exportConfig);
113113
const moduleExporter = new ModuleExporter(managementAPIClient, exportConfig);
114114
await moduleExporter.start();

packages/contentstack-export/src/utils/export-config-handler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import merge from 'merge';
22
import * as path from 'path';
3-
import { configHandler, isAuthenticated, FlagInput, cliux } from '@contentstack/cli-utilities';
3+
import { configHandler, isAuthenticated, FlagInput, cliux, sanitizePath } from '@contentstack/cli-utilities';
44
import defaultConfig from '../config';
55
import { readFile } from './file-helper';
66
import { askExportDir, askAPIKey } from './interactive';
@@ -15,14 +15,14 @@ const setupConfig = async (exportCmdFlags: any): Promise<ExportConfig> => {
1515
const externalConfig = await readFile(exportCmdFlags['config']);
1616
config = merge.recursive(config, externalConfig);
1717
}
18-
config.exportDir = exportCmdFlags['data'] || exportCmdFlags['data-dir'] || config.data || (await askExportDir());
18+
config.exportDir = sanitizePath(exportCmdFlags['data'] || exportCmdFlags['data-dir'] || config.data || (await askExportDir()));
1919

2020
const pattern = /[*$%#<>{}!&?]/g;
2121
if (pattern.test(config.exportDir)) {
2222
cliux.print(`\nPlease add a directory path without any of the special characters: (*,&,{,},[,],$,%,<,>,?,!)`, {
2323
color: 'yellow',
2424
});
25-
config.exportDir = await askExportDir();
25+
config.exportDir = sanitizePath(await askExportDir());
2626
}
2727
config.exportDir = config.exportDir.replace(/['"]/g, '');
2828
config.exportDir = path.resolve(config.exportDir);

packages/contentstack-export/src/utils/logger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ function init(_logPath: string) {
134134
}
135135

136136
export const log = async (config: ExportConfig, message: any, type: string) => {
137-
const logsPath = config.cliLogsPath || config.data;
137+
const logsPath = sanitizePath(config.cliLogsPath || config.data);
138138
// ignoring the type argument, as we are not using it to create a logfile anymore
139139
if (type !== 'error') {
140140
// removed type argument from init method

packages/contentstack-import-setup/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"@oclif/core": "^3.27.0",
1111
"big-json": "^3.2.0",
1212
"chalk": "^4.1.2",
13-
"fs-extra": "^11.1.1",
13+
"fs-extra": "^11.3.0",
1414
"lodash": "^4.17.21",
1515
"merge": "^2.1.1",
1616
"mkdirp": "^1.0.4",

packages/contentstack-import-setup/src/utils/import-config-handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ const setupConfig = async (importCmdFlags: any): Promise<ImportConfig> => {
2020
// config = merge.recursive(config, externalConfig);
2121
// }
2222

23-
config.contentDir = importCmdFlags['data'] || importCmdFlags['data-dir'] || config.data || (await askContentDir());
23+
config.contentDir = sanitizePath(importCmdFlags['data'] || importCmdFlags['data-dir'] || config.data || (await askContentDir()));
2424
const pattern = /[*$%#<>{}!&?]/g;
2525
if (pattern.test(config.contentDir)) {
2626
cliux.print(`\nPlease add a directory path without any of the special characters: (*,&,{,},[,],$,%,<,>,?,!)`, {
2727
color: 'yellow',
2828
});
29-
config.contentDir = await askContentDir();
29+
config.contentDir = sanitizePath(await askContentDir());
3030
}
3131
config.contentDir = config.contentDir.replace(/['"]/g, '');
3232
config.contentDir = path.resolve(config.contentDir);

packages/contentstack-import/src/utils/import-config-handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ const setupConfig = async (importCmdFlags: any): Promise<ImportConfig> => {
2020
config = merge.recursive(config, externalConfig);
2121
}
2222

23-
config.contentDir = importCmdFlags['data'] || importCmdFlags['data-dir'] || config.data || (await askContentDir());
23+
config.contentDir = sanitizePath(importCmdFlags['data'] || importCmdFlags['data-dir'] || config.data || (await askContentDir()));
2424
const pattern = /[*$%#<>{}!&?]/g;
2525
if (pattern.test(config.contentDir)) {
2626
cliux.print(`\nPlease add a directory path without any of the special characters: (*,&,{,},[,],$,%,<,>,?,!)`, {
2727
color: 'yellow',
2828
});
29-
config.contentDir = await askContentDir();
29+
config.contentDir = sanitizePath(await askContentDir());
3030
}
3131
config.contentDir = config.contentDir.replace(/['"]/g, '');
3232
config.contentDir = path.resolve(config.contentDir);

packages/contentstack-import/src/utils/logger.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import * as winston from 'winston';
88
import * as path from 'path';
9-
import mkdirp from 'mkdirp';
109
import { ImportConfig } from '../types';
1110
import { sanitizePath } from '@contentstack/cli-utilities';
1211

@@ -137,7 +136,7 @@ function init(_logPath: string) {
137136
}
138137

139138
export const log = async (config: ImportConfig, message: any, type: string) => {
140-
config.cliLogsPath = config.cliLogsPath || config.data || path.join(__dirname, 'logs');
139+
config.cliLogsPath = sanitizePath(config.cliLogsPath || config.data || path.join(__dirname, 'logs'));
141140
// ignoring the type argument, as we are not using it to create a logfile anymore
142141
if (type !== 'error') {
143142
// removed type argument from init method

packages/contentstack-migrate-rte/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
"dependencies": {
88
"@contentstack/cli-command": "~1.3.3",
99
"@contentstack/cli-utilities": "~1.8.1",
10-
"@contentstack/json-rte-serializer": "~2.0.11",
10+
"@contentstack/json-rte-serializer": "~2.0.12",
1111
"collapse-whitespace": "^1.1.7",
1212
"chalk": "^4.1.2",
1313
"jsdom": "^20.0.3",
14-
"jsonschema": "^1.4.1",
14+
"jsonschema": "^1.5.0",
1515
"lodash": "^4.17.21",
16-
"nock": "^13.5.5",
16+
"nock": "^13.5.6",
1717
"omit-deep-lodash": "^1.1.7",
1818
"sinon": "^19.0.2"
1919
},
2020
"devDependencies": {
21-
"@oclif/test": "^4.1.6",
21+
"@oclif/test": "^4.1.9",
2222
"chai": "^4.5.0",
2323
"eslint": "^8.57.1",
2424
"eslint-config-oclif": "^4.0.0",

packages/contentstack-migration/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"winston": "^3.17.0"
1616
},
1717
"devDependencies": {
18-
"@oclif/test": "^4.1.6",
18+
"@oclif/test": "^4.1.9",
1919
"chai": "^4.5.0",
2020
"eslint": "^8.57.1",
2121
"jsdoc-to-markdown": "^8.0.3",

0 commit comments

Comments
 (0)