handsontable / hyperformula

HyperFormula is an open-source headless spreadsheet for business web apps. It comes with over 400 formulas, CRUD operations, undo-redo, clipboard support, and sorting.
https://hyperformula.handsontable.com/
Other
1.97k stars 108 forks source link

Fix function SUBSTITUTE with special characters #1347

Closed sequba closed 9 months ago

sequba commented 10 months ago

Context

Our implementation of the function SUBSTITUTE uses regular expressions to search for a substring in the input text. It returns an incorrect result if the search string contains RegExp special characters (., *, [, etc.). This PR adds special characters escaping to fix it.

How did you test your changes?

Types of changes

Related issues:

Fixes #1289

Checklist:

github-actions[bot] commented 10 months ago

Performance comparison of head (84078c6ce8c6c23bfcae7d3e1d6c49df72ec4a45) vs base (0c1d4645327790c02ac336a5635d573fe8add6d1)

                                     testName |   base |   head |  change
-------------------------------------------------------------------------
                                      Sheet A | 545.18 | 555.54 |  +1.90%
                                      Sheet B | 182.08 | 181.69 |  -0.21%
                                      Sheet T | 159.45 | 157.91 |  -0.97%
                                Column ranges | 564.77 | 563.17 |  -0.28%
Sheet A:  change value, add/remove row/column |     38 |     41 |  +7.89%
 Sheet B: change value, add/remove row/column |    274 |    285 |  +4.01%
                   Column ranges - add column |    177 |    158 | -10.73%
                Column ranges - without batch |    381 |    523 | +37.27%
                        Column ranges - batch |    135 |    134 |  -0.74%
codecov[bot] commented 9 months ago

Codecov Report

Merging #1347 (84078c6) into develop (0c1d464) will increase coverage by 0.00%. The diff coverage is 100.00%.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/handsontable/hyperformula/pull/1347/graphs/tree.svg?width=650&height=150&src=pr&token=5k9ZQv8azO&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=handsontable)](https://app.codecov.io/gh/handsontable/hyperformula/pull/1347?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=handsontable) ```diff @@ Coverage Diff @@ ## develop #1347 +/- ## ======================================== Coverage 97.28% 97.28% ======================================== Files 169 169 Lines 14422 14425 +3 Branches 3081 3081 ======================================== + Hits 14030 14033 +3 Misses 387 387 Partials 5 5 ``` | [Files](https://app.codecov.io/gh/handsontable/hyperformula/pull/1347?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=handsontable) | Coverage Δ | | |---|---|---| | [src/interpreter/plugin/TextPlugin.ts](https://app.codecov.io/gh/handsontable/hyperformula/pull/1347?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=handsontable#diff-c3JjL2ludGVycHJldGVyL3BsdWdpbi9UZXh0UGx1Z2luLnRz) | `100.00% <100.00%> (ø)` | |