SEPURI-SAI-KRISHNA opened a new pull request, #45407:
URL: https://github.com/apache/superset/pull/45407

   ### SUMMARY
   
   Fixes #45406.
   
   The chart XLSX formula guard in `superset/utils/excel.py` checked 
`value[0]`, so
   leading whitespace let a formula through unquoted. `" =1+1"`, `"\t=1+1"` and
   `"  @SUM(A1)"` were written as live formulas. The streaming writer
   (`excel_streaming.py`) and the CSV writer already `lstrip()` before checking,
   and the comment on the shared `FORMULA_PREFIXES` constant says both export 
paths
   agree, which was not the case.
   
   The fix strips before inspecting the first character, mirroring the streaming
   writer. The CSV-only extras (`|`, `%`, doubled-quote, negative-number 
handling)
   are left alone, so the diff is only the one inconsistency.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   Before (`df_to_excel` then `pd.read_excel`):
   
   ```
   ' =1+1'       -> ' =1+1'      (live formula)
   '\t=1+1'      -> '\t=1+1'     (live formula)
   '  @SUM(A1)'  -> '  @SUM(A1)' (live formula)
   ```
   
   After:
   
   ```
   ' =1+1'       -> "' =1+1"      (neutralised text)
   '\t=1+1'      -> "'\t=1+1"     (neutralised text)
   '  @SUM(A1)'  -> "'  @SUM(A1)" (neutralised text)
   ```
   
   ### TESTING INSTRUCTIONS
   
   ```
   pytest tests/unit_tests/utils/excel_tests.py
   ```
   
   New `test_quote_formulas_with_leading_whitespace` fails on the old guard and
   passes with the fix; the existing `test_quote_formulas` still passes.
   
   ### ADDITIONAL INFORMATION
   
   - [x] Has associated issue: #45406
   - [ ] 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]

Reply via email to