Skip to content

Commit

Permalink
Fix export formatted csv data with special characters from tables (#7048
Browse files Browse the repository at this point in the history
)

* Scape doublequotes on export

* Add sanitize to the new line character

* Update CHANGELOG

* Apply prettier

* Apply prettier

* Scape linebreak

---------

Co-authored-by: Federico Rodriguez <federico.rodriguez@wazuh.com>
  • Loading branch information
Machi3mfl and asteriscos authored Oct 2, 2024
1 parent d3f1dd5 commit 8b18817
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(',');
})
Expand Down

0 comments on commit 8b18817

Please sign in to comment.