Fix/csv escaping 1052 - #1128
Closed
MILAN-123865 wants to merge 2 commits into
Closed
Conversation
|
@MILAN-123865 is attempting to deploy a commit to the Aditya Mahajan's projects Team on Vercel. A member of the Team first needs to authorize it. |
Thank You for Your Contribution! 🎉Hi @MILAN-123865, Thank you for opening this Pull Request and contributing to our project. We truly appreciate your efforts.
The maintainer @Aditya8369 will review your PR shortly! Happy Contributing! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Description
Please provide a brief summary of your changes.
Related Issue
Closes #
Type of Change
Changes Made
Testing
Screenshots
If applicable, attach screenshots or screen recordings.
Checklist
Additional Notes
Add any additional information for reviewers here.
Description
This PR addresses data corruption and spreadsheet injection vulnerabilities (CSV Injection) across our exporting utilities. By deploying a robust, centralized CSV cell-sanitization engine that adheres strictly to RFC 4180 rules, this fix ensures that embedded delimiters or newlines do not shift tracking grids. Furthermore, it sanitizes leading characters that could trigger malicious formula execution upon ingestion by external spreadsheet programs.
Changes
src/utils/csvEngine.js: Introduced a centralized, safe cell processing utility (escapeCSVField) and row compiler to wrap unsafe fields, escape quotes, and neutralize spreadsheet formula characters (=,+,-,@,\t,\r) with a safe leading single-quote prefix.src/utils/reportExporter.js&src/services/historicalDataService.js: Refactored mapping logic to utilize the shared escaping abstraction and safely handle instances whereexceedanceslists are missing without throwing aTypeError.Verification Results
PM2.5, respirableare accurately wrapped in quotes ("PM2.5, respirable") and do not spawn artificial trailing rows.=HYPERLINK(...)migrate strictly as safe literal strings ("'=HYPERLINK(...)").undefinedornullvalues into output rows.Closes #1052