summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/util
diff options
context:
space:
mode:
authorZsolt Kozaroczy <[email protected]>2023-05-17 10:08:04 +0200
committerGitHub <[email protected]>2023-05-17 10:08:04 +0200
commit3e6badd102edd9f4ec54b12ead2e769474e4a045 (patch)
treec35b58dca864ad0f4800445e58e2ca2eca01d31b /lib/axlsx/util
parent7d70e17cd818958eac09f68c8886b9664aa4ad8c (diff)
parent7899578ad12fb710cbdf74e1aa87e2190c5832ed (diff)
downloadcaxlsx-3e6badd102edd9f4ec54b12ead2e769474e4a045.tar.gz
caxlsx-3e6badd102edd9f4ec54b12ead2e769474e4a045.zip
Merge branch 'master' into serializedAttributes
Diffstat (limited to 'lib/axlsx/util')
-rw-r--r--lib/axlsx/util/constants.rb12
-rw-r--r--lib/axlsx/util/validators.rb4
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/axlsx/util/constants.rb b/lib/axlsx/util/constants.rb
index 4697bb3a..5ef3ece1 100644
--- a/lib/axlsx/util/constants.rb
+++ b/lib/axlsx/util/constants.rb
@@ -413,4 +413,16 @@ module Axlsx
# Numeric recognition
NUMERIC_REGEX = /\A[+-]?\d+?\Z/.freeze
+
+ # Leading characters that indicate a formula.
+ # See: https://owasp.org/www-community/attacks/CSV_Injection
+ FORMULA_PREFIX = '='
+
+ # Leading characters that indicate an array formula.
+ ARRAY_FORMULA_PREFIX = '{='
+
+ # Trailing character that indicates an array formula.
+ ARRAY_FORMULA_SUFFIX = '}'
+
+ BOOLEAN_VALUES = [true, false].freeze
end
diff --git a/lib/axlsx/util/validators.rb b/lib/axlsx/util/validators.rb
index 0004f51a..e9cf13b6 100644
--- a/lib/axlsx/util/validators.rb
+++ b/lib/axlsx/util/validators.rb
@@ -106,8 +106,8 @@ module Axlsx
DataTypeValidator.validate :signed_int, Integer, v
end
- VALID_BOOLEAN_CLASSES = [String, Integer, Symbol, TrueClass, FalseClass].freeze
- VALID_BOOLEAN_VALUES = [0, 1, 'true', 'false', :true, :false, true, false, '0', '1'].freeze
+ VALID_BOOLEAN_CLASSES = [TrueClass, FalseClass, Integer, String, Symbol].freeze
+ VALID_BOOLEAN_VALUES = [true, false, 1, 0, '1', '0', 'true', 'false', :true, :false].freeze
BOOLEAN_VALIDATOR = lambda { |arg| VALID_BOOLEAN_VALUES.include?(arg) }
# Requires that the value is a form that can be evaluated as a boolean in an xml document.