modified .replace to delete double quotes
(on values to be put in csv)
MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -1545,7 +1545,7 @@ export default class ChargingStationService {
Utils.replaceSpecialCharsInCSVValueParam(param.value),
ocppParams.siteAreaName,
ocppParams.siteName,
- ].map((value) => typeof value === 'string' ? '"' + value.replace('"', '""') + '"' : value);
+ ].map((value) => typeof value === 'string' ? '"' + value.replace(/^"|"$/g, '') + '"' : value);
return row;
}).join(Constants.CR_LF);
return Utils.isNullOrUndefined(headers) ? Constants.CR_LF + rows : [headers, rows].join(Constants.CR_LF);
@@ -1609,7 +1609,7 @@ export default class ChargingStationService {
i18nManager.formatDateTime(chargingStation.lastReboot, 'L') + ' ' + i18nManager.formatDateTime(chargingStation.lastReboot, 'LT'),
chargingStation.maximumPower,
chargingStation.powerLimitUnit
- ].map((value) => typeof value === 'string' ? '"' + value.replace('"', '""') + '"' : value);
+ ].map((value) => typeof value === 'string' ? '"' + value.replace(/^"|"$/g, '') + '"' : 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) => typeof value === 'string' ? '"' + value.replace('"', '""') + '"' : value);
+ ].map((value) => typeof value === 'string' ? '"' + value.replace(/^"|"$/g, '') + '"' : 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
@@ -639,7 +639,7 @@ export default class StatisticService {
year && year !== '0' ? year : '',
transaction._id.month > 0 ? transaction._id.month : '',
dataType === 'Pricing' ? StatisticService.getPricingCell(transaction, numberOfTransaction) : numberOfTransaction.toString()
- ].map((value) => typeof value === 'string' ? '"' + value.replace('"', '""') + '"' : value);
+ ].map((value) => typeof value === 'string' ? '"' + value.replace(/^"|"$/g, '') + '"' : value);
return row;
}).join(Constants.CR_LF);
return [headers, rows].join(Constants.CR_LF);

MODIFY
src/server/rest/v1/service/TransactionService.ts
src/server/rest/v1/service/TransactionService.ts
@@ -939,7 +939,7 @@ export default class TransactionService {
transaction.stop ? Math.round(transaction.stop.totalInactivitySecs ? transaction.stop.totalInactivitySecs / 60 : 0) : '',
transaction.stop ? transaction.stop.roundedPrice : '',
transaction.stop ? transaction.stop.priceUnit : ''
- ].map((value) => typeof value === 'string' ? '"' + value.replace('"', '""') + '"' : value);
+ ].map((value) => typeof value === 'string' ? '"' + value.replace(/^"|"$/g, '') + '"' : 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
@@ -1278,7 +1278,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) => typeof value === 'string' ? '"' + value.replace('"', '""') + '"' : value);
+ ].map((value) => typeof value === 'string' ? '"' + value.replace(/^"|"$/g, '') + '"' : value);
return row;
}).join(Constants.CR_LF);
return Utils.isNullOrUndefined(headers) ? Constants.CR_LF + rows : [headers, rows].join(Constants.CR_LF);

modified .replace to delete double quotes
(on values to be put in csv)