diff options
| author | johnnyshields <[email protected]> | 2023-04-22 08:52:32 +0900 |
|---|---|---|
| committer | Stefan Daschek <[email protected]> | 2023-04-23 00:46:54 +0200 |
| commit | c2ef35053983b5e42f604b99dee7591ad0a913fa (patch) | |
| tree | 414c071e56b7c6e23c4ab418ee4e8d9629debaab /lib | |
| parent | ec018a0075744e982ead45dee73691aadfaedab0 (diff) | |
| download | caxlsx-c2ef35053983b5e42f604b99dee7591ad0a913fa.tar.gz caxlsx-c2ef35053983b5e42f604b99dee7591ad0a913fa.zip | |
Revert formula characters other than =
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/axlsx/workbook/worksheet/cell.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/axlsx/workbook/worksheet/cell.rb b/lib/axlsx/workbook/worksheet/cell.rb index 5e2661c3..508e9dd8 100644 --- a/lib/axlsx/workbook/worksheet/cell.rb +++ b/lib/axlsx/workbook/worksheet/cell.rb @@ -72,7 +72,13 @@ module Axlsx # Leading characters that indicate a formula. # See: https://owasp.org/www-community/attacks/CSV_Injection - FORMULA_PREFIXES = ['-', '=', '+', '@', '%', '|', "\r", "\t"].freeze + FORMULA_PREFIXES = ['='.freeze].freeze + + # Leading characters that indicate an array formula. + ARRAY_FORMULA_PREFIXES = ['{='.freeze].freeze + + # Trailing character that indicates an array formula. + ARRAY_FORMULA_SUFFIX = '}'.freeze # The index of the cellXfs item to be applied to this cell. # @return [Integer] @@ -393,7 +399,9 @@ module Axlsx def is_array_formula? return false if escape_formulas - type == :string && @value.to_s.start_with?('{=') && @value.to_s.end_with?('}') + type == :string && + @value.to_s.start_with?(*ARRAY_FORMULA_PREFIXES) && + @value.to_s.end_with?(ARRAY_FORMULA_SUFFIX) end # returns the absolute or relative string style reference for |
