Skip to content

Commit

Permalink
Remove useless use of freeze
Browse files Browse the repository at this point in the history
  • Loading branch information
felixbuenemann committed Dec 28, 2024
1 parent 5be6b98 commit def68d2
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/xlsxtream/xml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ module XML
}.freeze

# Escape first underscore of ST_Xstring sequences in input strings to appear as plaintext in Excel
HEX_ESCAPE_REGEXP = /_(x[0-9A-Fa-f]{4}_)/.freeze
XML_ESCAPE_UNDERSCORE = '_x005f_\1'.freeze
HEX_ESCAPE_REGEXP = /_(x[0-9A-Fa-f]{4}_)/
XML_ESCAPE_UNDERSCORE = '_x005f_\1'

XML_DECLARATION = %'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n'.freeze
XML_DECLARATION = %'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n'

WS_AROUND_TAGS = /(?<=>)\s+|\s+(?=<)/.freeze
WS_AROUND_TAGS = /(?<=>)\s+|\s+(?=<)/

UNSAFE_ATTR_CHARS = /[&"<>]/.freeze
UNSAFE_VALUE_CHARS = /[&<>]/.freeze
UNSAFE_ATTR_CHARS = /[&"<>]/
UNSAFE_VALUE_CHARS = /[&<>]/

# http://www.w3.org/TR/REC-xml/#NT-Char:
# Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
INVALID_XML10_CHARS = /[^\x09\x0A\x0D\x20-\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}]/.freeze
INVALID_XML10_CHARS = /[^\x09\x0A\x0D\x20-\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}]/

# ST_Xstring escaping
ESCAPE_CHAR = lambda { |c| '_x%04X_'.freeze % c.ord }.freeze
ESCAPE_CHAR = lambda { |c| '_x%04X_' % c.ord }

class << self

Expand All @@ -33,7 +33,7 @@ def header
end

def strip(xml)
xml.gsub(WS_AROUND_TAGS, ''.freeze)
xml.gsub(WS_AROUND_TAGS, '')
end

def escape_attr(string)
Expand Down

0 comments on commit def68d2

Please sign in to comment.