Skip to content

Fix/csv escaping 1052 - #1128

Closed
MILAN-123865 wants to merge 2 commits into
Aditya8369:mainfrom
MILAN-123865:fix/csv-escaping-1052
Closed

Fix/csv escaping 1052#1128
MILAN-123865 wants to merge 2 commits into
Aditya8369:mainfrom
MILAN-123865:fix/csv-escaping-1052

Conversation

@MILAN-123865

Copy link
Copy Markdown
Contributor

Pull Request

Description

Please provide a brief summary of your changes.


Related Issue

Closes #


Type of Change

  • Bug Fix
  • New Feature
  • Documentation
  • UI/UX Improvement
  • Refactoring
  • Performance Improvement
  • Accessibility

Changes Made


Testing

  • Tested locally
  • No console errors
  • Existing functionality works as expected

Screenshots

If applicable, attach screenshots or screen recordings.


Checklist

  • My code follows the project guidelines.
  • I have tested my changes.
  • I have updated the documentation if required.
  • My changes address the related issue.
  • This PR focuses on a single issue.

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 where exceedances lists are missing without throwing a TypeError.

Verification Results

  • Verified that fields like PM2.5, respirable are accurately wrapped in quotes ("PM2.5, respirable") and do not spawn artificial trailing rows.
  • Confirmed that executable cells like =HYPERLINK(...) migrate strictly as safe literal strings ("'=HYPERLINK(...)").
  • Verified that missing payload values degrade gracefully to blank cell blocks rather than injecting literal undefined or null values into output rows.

Closes #1052

@vercel

vercel Bot commented Aug 29, 2026

Copy link
Copy Markdown

@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.

@github-actions

Copy link
Copy Markdown

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.

Please make sure that:

  • Your code follows the project's guidelines.
  • You have linked the appropriate issue (if applicable).
  • Screenshots are added for UI/UX changes.
  • Your PR is ready for review.

The maintainer @Aditya8369 will review your PR shortly!

Happy Contributing! 🚀

@github-actions github-actions Bot added the ECSoC26 Contributions considered under ECSoC'26 label Aug 29, 2026
@Aditya8369 Aditya8369 closed this Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ECSoC26 Contributions considered under ECSoC'26

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CSV exports are unescaped: a comma in a value shifts every later column, and a leading = runs as a formula when the file is opened

2 participants