modified :
escapeCsvValues to escapeCsvValue
unEscapeCsvValues to unescapeCsvValue
MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -1455,7 +1455,7 @@ export default class ChargingStationService {
Utils.replaceSpecialCharsInCSVValueParam(param.value),
ocppParams.siteAreaName,
ocppParams.siteName,
- ].map((value) => Utils.escapeCsvValues(value));
+ ].map((value) => Utils.escapeCsvValue(value));
return row;
}).join(Constants.CR_LF);
return Utils.isNullOrUndefined(headers) ? Constants.CR_LF + rows : [headers, rows].join(Constants.CR_LF);
@@ -1519,7 +1519,7 @@ export default class ChargingStationService {
i18nManager.formatDateTime(chargingStation.lastReboot, 'L') + ' ' + i18nManager.formatDateTime(chargingStation.lastReboot, 'LT'),
chargingStation.maximumPower,
chargingStation.powerLimitUnit
- ].map((value) => Utils.escapeCsvValues(value));
+ ].map((value) => Utils.escapeCsvValue(value));
return row;
}).join(Constants.CR_LF);
return Utils.isNullOrUndefined(headers) ? Constants.CR_LF + rows : [headers, rows].join(Constants.CR_LF);

MODIFY
src/server/rest/v1/service/LoggingService.ts
src/server/rest/v1/service/LoggingService.ts
@@ -85,7 +85,7 @@ export default class LoggingService {
log.source,
log.host,
log.process
- ].map((value) => Utils.escapeCsvValues(value));
+ ].map((value) => Utils.escapeCsvValue(value));
return row;
}).join(Constants.CR_LF);
return Utils.isNullOrUndefined(headers) ? Constants.CR_LF + rows : [headers, rows].join(Constants.CR_LF);

MODIFY
src/server/rest/v1/service/StatisticService.ts
src/server/rest/v1/service/StatisticService.ts
@@ -652,7 +652,7 @@ export default class StatisticService {
year && year !== '0' ? year : '',
transaction.month > 0 ? transaction.month : '',
dataType === StatsDataType.PRICING ? StatisticService.getPricingCell(transaction, numberOfTransactions) : numberOfTransactions.toString()
- ].map((value) => Utils.escapeCsvValues(value));
+ ].map((value) => Utils.escapeCsvValue(value));
return row;
}).join(Constants.CR_LF);
return [headers, rows].join(Constants.CR_LF);

MODIFY
src/server/rest/v1/service/TagService.ts
src/server/rest/v1/service/TagService.ts
@@ -714,7 +714,7 @@ export default class TagService {
tag.user?.firstName,
tag.user?.name,
tag.user?.email
- ].map((value) => Utils.escapeCsvValues(value));
+ ].map((value) => Utils.escapeCsvValue(value));
return row;
}).join(Constants.CR_LF);
return Utils.isNullOrUndefined(headers) ? Constants.CR_LF + rows : [headers, rows].join(Constants.CR_LF);
@@ -761,10 +761,10 @@ export default class TagService {
try {
const newImportedTag: ImportedTag = {
id: importedTag.id.toUpperCase(),
- description: importedTag.description ? Utils.escapeCsvValues(importedTag.description) : `Badge ID '${importedTag.id}'`,
- name: Utils.escapeCsvValues(importedTag.name.toUpperCase()),
- firstName: Utils.escapeCsvValues(importedTag.firstName),
- email: Utils.escapeCsvValues(importedTag.email),
+ description: importedTag.description ? Utils.escapeCsvValue(importedTag.description) : `Badge ID '${importedTag.id}'`,
+ name: Utils.escapeCsvValue(importedTag.name.toUpperCase()),
+ firstName: Utils.escapeCsvValue(importedTag.firstName),
+ email: Utils.escapeCsvValue(importedTag.email),
};
// Validate Tag data
TagValidator.getInstance().validateImportedTagCreation(newImportedTag);

MODIFY
src/server/rest/v1/service/TransactionService.ts
src/server/rest/v1/service/TransactionService.ts
@@ -929,7 +929,7 @@ export default class TransactionService {
(transaction.stop.totalInactivitySecs ? Utils.truncTo(Utils.createDecimal(transaction.stop.totalInactivitySecs).div(60).toNumber(), 2) : 0) : '',
transaction.stop ? transaction.stop.roundedPrice : '',
transaction.stop ? transaction.stop.priceUnit : ''
- ].map((value) => Utils.escapeCsvValues(value));
+ ].map((value) => Utils.escapeCsvValue(value));
return row;
}).join(Constants.CR_LF);
return Utils.isNullOrUndefined(headers) ? Constants.CR_LF + rows : [headers, rows].join(Constants.CR_LF);

MODIFY
src/server/rest/v1/service/UserService.ts
src/server/rest/v1/service/UserService.ts
@@ -1276,7 +1276,7 @@ export default class UserService {
moment(user.createdOn).format('YYYY-MM-DD'),
moment(user.lastChangedOn).format('YYYY-MM-DD'),
(user.lastChangedBy ? Utils.buildUserFullName(user.lastChangedBy as User, false) : '')
- ].map((value) => Utils.escapeCsvValues(value));
+ ].map((value) => Utils.escapeCsvValue(value));
return row;
}).join(Constants.CR_LF);
return Utils.isNullOrUndefined(headers) ? Constants.CR_LF + rows : [headers, rows].join(Constants.CR_LF);
@@ -1341,9 +1341,9 @@ export default class UserService {
private static async processUser(action: ServerAction, req: Request, importedUser: ImportedUser, usersToBeImported: ImportedUser[]): Promise<boolean> {
try {
const newImportedUser: ImportedUser = {
- name: Utils.escapeCsvValues(importedUser.name.toUpperCase()),
- firstName: Utils.escapeCsvValues(importedUser.firstName),
- email: Utils.escapeCsvValues(importedUser.email),
+ name: Utils.escapeCsvValue(importedUser.name.toUpperCase()),
+ firstName: Utils.escapeCsvValue(importedUser.firstName),
+ email: Utils.escapeCsvValue(importedUser.email),
};
// Validate User data

MODIFY
src/storage/mongodb/TagStorage.ts
src/storage/mongodb/TagStorage.ts
@@ -42,10 +42,10 @@ export default class TagStorage {
const uniqueTimerID = Logging.traceStart(tenantID, MODULE_NAME, 'saveImportedTag');
const tagMDB = {
_id: importedTagToSave.id,
- description: Utils.unEscapeCsvValues(importedTagToSave.description),
- name: Utils.unEscapeCsvValues(importedTagToSave.name),
- firstName: Utils.unEscapeCsvValues(importedTagToSave.firstName),
- email: Utils.unEscapeCsvValues(importedTagToSave.email),
+ description: Utils.unescapeCsvValue(importedTagToSave.description),
+ name: Utils.unescapeCsvValue(importedTagToSave.name),
+ firstName: Utils.unescapeCsvValue(importedTagToSave.firstName),
+ email: Utils.unescapeCsvValue(importedTagToSave.email),
status: importedTagToSave.status,
errorDescription: importedTagToSave.errorDescription,
importedOn: Utils.convertToDate(importedTagToSave.importedOn),
@@ -65,10 +65,10 @@ export default class TagStorage {
const uniqueTimerID = Logging.traceStart(tenantID, MODULE_NAME, 'saveImportedTags');
const importedTagsToSaveMDB: any = importedTagsToSave.map((importedTagToSave) => ({
_id: importedTagToSave.id,
- description: Utils.unEscapeCsvValues(importedTagToSave.description),
- name: Utils.unEscapeCsvValues(importedTagToSave.name),
- firstName: Utils.unEscapeCsvValues(importedTagToSave.firstName),
- email: Utils.unEscapeCsvValues(importedTagToSave.email),
+ description: Utils.unescapeCsvValue(importedTagToSave.description),
+ name: Utils.unescapeCsvValue(importedTagToSave.name),
+ firstName: Utils.unescapeCsvValue(importedTagToSave.firstName),
+ email: Utils.unescapeCsvValue(importedTagToSave.email),
status: importedTagToSave.status,
errorDescription: importedTagToSave.errorDescription,
importedOn: Utils.convertToDate(importedTagToSave.importedOn),

MODIFY
src/utils/Utils.ts
src/utils/Utils.ts
@@ -1498,13 +1498,13 @@ export default class Utils {
return Configuration.isCloudFoundry() ? cfenv.getAppEnv().name : os.hostname();
}
- public static escapeCsvValues(value: any): string {
+ public static escapeCsvValue(value: any): string {
// replace starting and ending double quotes by nothing
// replace double quotes inside value to double double quotes to display double quote in csv editor
return typeof value === 'string' ? '"' + value.replace(/^"|"$/g, '').replace(/"/g, '""') + '"' : value;
}
- public static unEscapeCsvValues(value: any): string {
+ public static unescapeCsvValue(value: any): string {
// replace double double quotes inside value into simple double quotes
return typeof value === 'string' ? value.replace(/""/g, '"') : value;
}

modified :
- escapeCsvValues to escapeCsvValue
- unEscapeCsvValues to unescapeCsvValue