dhimasardinata opened a new pull request, #40195: URL: https://github.com/apache/superset/pull/40195
### SUMMARY Avoid running two regular expressions for every CSV cell passed through `escape_value()`. The CSV export path can call this for every object-valued cell and header, so replacing the regex checks with direct prefix checks keeps the existing CSV injection behavior while reducing per-cell overhead. The implementation preserves the currently tested cases for formula prefixes, doubled-quote prefixes, leading whitespace, pipe escaping, and negative numeric values. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF Not applicable. ### TESTING INSTRUCTIONS Ran locally: ```bash python3 -m py_compile superset/utils/csv.py ``` Also ran a local microbenchmark comparing the previous regex logic with this implementation over mixed dashboard/CSV export values: ```text old: per_call_us min/med/max=2.006/2.746/4.318 patched: per_call_us min/med/max=1.617/2.015/2.696 patched_speedup_vs_old=1.36x ``` `python3 -m pytest tests/unit_tests/utils/csv_tests.py -q` was not runnable in this local checkout because `pytest` is not installed. ### ADDITIONAL INFORMATION - [ ] Has associated issue: - [ ] Required feature flags: - [ ] Changes UI - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351)) - [ ] Migration is atomic, supports rollback & is backwards-compatible - [ ] Confirm DB migration upgrade and downgrade tested - [ ] Runtime estimates and downtime expectations provided - [ ] Introduces new feature or API - [ ] Removes existing feature or API -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
