Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix code scanning alert no. 2: Incomplete string escaping or encoding #7

Merged
merged 1 commit into from
Dec 30, 2024

Conversation

ccxzhang
Copy link
Member

Fixes https://github.com/worldbank/DHIS2-Downloader/security/code-scanning/2

To fix the problem, we need to ensure that both double quotes and backslashes are properly escaped in the CSV output. This can be achieved by first escaping backslashes and then escaping double quotes. The order of escaping is important to avoid double-escaping backslashes.

The best way to fix this is to update the objectToCsv function to use a regular expression that handles both backslashes and double quotes. We will replace the current replace call with a more comprehensive one that escapes both characters.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@ccxzhang ccxzhang self-assigned this Dec 30, 2024
@ccxzhang ccxzhang marked this pull request as ready for review December 30, 2024 18:30
@ccxzhang ccxzhang merged commit 62dbe14 into main Dec 30, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant