diff --git a/CHANGELOG.md b/CHANGELOG.md index f1cac93806..c8f3be31da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ All notable changes to the Wazuh app project will be documented in this file. - Fixed read-only users could not access to Statistics application [#7001](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7001) - Fixed no-agent-alert spawn with selected agent in agent-welcome view [#7029](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7029) - Fixed security policy exception when it contained deprecated actions [#7042](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7042) +- Fix export formatted csv data with special characters from tables [#7048](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7048) ### Removed diff --git a/plugins/main/public/components/common/data-grid/data-grid-service.ts b/plugins/main/public/components/common/data-grid/data-grid-service.ts index 35151a2f2d..bdd6cace7e 100644 --- a/plugins/main/public/components/common/data-grid/data-grid-service.ts +++ b/plugins/main/public/components/common/data-grid/data-grid-service.ts @@ -170,7 +170,12 @@ export const exportSearchToCSV = async ( if (typeof value === 'object') { return JSON.stringify(value); } - return `"${value}"`; + // Escape double quotes and handle line breaks to prevent column misalignment + return `"${value + .toString() + .replaceAll(/"/g, '""') + .replaceAll(/\r\n/g, '\\r\\n') + .replaceAll(/\n/g, '\\n')}"`; }); return parsedRow?.join(','); })