summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorWinfield Peterson <[email protected]>2017-11-30 10:36:20 -0500
committerWinfield Peterson <[email protected]>2017-11-30 10:36:20 -0500
commitccc69882c6ec4fb8286282313620bceac32e592d (patch)
tree0b67891631ef4d42dfbbdab8a6c5458ae28725f8 /lib
parente50f636dc0d2cd96772a6b55934bf9a7773f21fa (diff)
downloadcaxlsx-ccc69882c6ec4fb8286282313620bceac32e592d.tar.gz
caxlsx-ccc69882c6ec4fb8286282313620bceac32e592d.zip
Axlsx.sanitize() writes in place or copies on write
Depending on whether a string is frozen, either a new string is created sanitized or the existing string is modified in place.
Diffstat (limited to 'lib')
-rw-r--r--lib/axlsx.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/axlsx.rb b/lib/axlsx.rb
index 20b5cab0..586562f6 100644
--- a/lib/axlsx.rb
+++ b/lib/axlsx.rb
@@ -136,8 +136,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