summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorrandym <[email protected]>2018-02-07 11:21:00 +0900
committerrandym <[email protected]>2018-02-07 11:21:00 +0900
commit3f34514ecf53fb4a3401b5336833bbeb439efe2a (patch)
tree5a911a498db05f87756313e6d737e866dd37d176
parent14c05d69ddf555528bb20991d289454d5350969c (diff)
parent545d77371cf81c368ccfd761e5409cbc7e141711 (diff)
downloadcaxlsx-3f34514ecf53fb4a3401b5336833bbeb439efe2a.tar.gz
caxlsx-3f34514ecf53fb4a3401b5336833bbeb439efe2a.zip
Merge branch 'master' into release-3.0.0
-rw-r--r--lib/axlsx.rb8
-rw-r--r--lib/axlsx/stylesheet/styles.rb2
-rw-r--r--test/tc_axlsx.rb21
3 files changed, 28 insertions, 3 deletions
diff --git a/lib/axlsx.rb b/lib/axlsx.rb
index 387a8b89..23fc6c8b 100644
--- a/lib/axlsx.rb
+++ b/lib/axlsx.rb
@@ -135,8 +135,12 @@ module Axlsx
# @param [String] str The string to process
# @return [String]
def self.sanitize(str)
- str.delete!(CONTROL_CHARS)
- str
+ if str.frozen?
+ str.delete(CONTROL_CHARS)
+ else
+ str.delete!(CONTROL_CHARS)
+ str
+ end
end
# If value is boolean return 1 or 0
diff --git a/lib/axlsx/stylesheet/styles.rb b/lib/axlsx/stylesheet/styles.rb
index c7283324..2460ab10 100644
--- a/lib/axlsx/stylesheet/styles.rb
+++ b/lib/axlsx/stylesheet/styles.rb
@@ -128,7 +128,7 @@ module Axlsx
# @option options [Boolean] i Indicates if the text should be italicised
# @option options [Boolean] u Indicates if the text should be underlined
# @option options [Boolean] strike Indicates if the text should be rendered with a strikethrough
- # @option options [Boolean] strike Indicates if the text should be rendered with a shadow
+ # @option options [Boolean] shadow Indicates if the text should be rendered with a shadow
# @option options [Integer] charset The character set to use.
# @option options [Integer] family The font family to use.
# @option options [String] font_name The name of the font to use
diff --git a/test/tc_axlsx.rb b/test/tc_axlsx.rb
index 99832f63..3d6a2e70 100644
--- a/test/tc_axlsx.rb
+++ b/test/tc_axlsx.rb
@@ -79,4 +79,25 @@ class TestAxlsx < Test::Unit::TestCase
assert_equal([['Z5', 'AA5', 'AB5'], ['Z6', 'AA6', 'AB6']], Axlsx::range_to_a('Z5:AB6'))
end
+ def test_sanitize_frozen_control_strippped
+ needs_sanitize = "legit\x08".freeze # Backspace control char
+
+ assert_equal(Axlsx.sanitize(needs_sanitize), 'legit', 'should strip control chars')
+ end
+
+ def test_sanitize_unfrozen_control_strippped
+ needs_sanitize = "legit\x08" # Backspace control char
+ sanitized_str = Axlsx.sanitize(needs_sanitize)
+
+ assert_equal(sanitized_str, 'legit', 'should strip control chars')
+ assert_equal(sanitized_str.object_id, sanitized_str.object_id, 'should preserve object')
+ end
+
+ def test_sanitize_unfrozen_no_sanitize
+ legit_str = 'legit'
+ sanitized_str = Axlsx.sanitize(legit_str)
+
+ assert_equal(sanitized_str, legit_str, 'should preserve value')
+ assert_equal(sanitized_str.object_id, legit_str.object_id, 'should preserve object')
+ end
end