xlsxtream 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e14836ad11f003e4019482eaf41eaf3a9ff76cb2dd61936a38b295e3b8e95b1a
4
- data.tar.gz: 1603a0f3563d7c1f433ccaea41f73afca61603165d02d3c6b984225fecbb4cce
3
+ metadata.gz: '08866e063a1979a9dfb695f2bf85bd97536b85da709ee87b107bb534930009fd'
4
+ data.tar.gz: 4673dab9359e7abf3f85e8e44ac5927a4cf60bdb0e0b39ba3efcd11a17e56a74
5
5
  SHA512:
6
- metadata.gz: e196498e8816bd269ad49f09fb47774b19518b3add9f4b466be2bb919b87bae5d48539209357f3fa124671586352b5b473af49b7175349d83066db2bbc10e17f
7
- data.tar.gz: 86f3dd5355883938d09c38f2c20d8840c650be9bea551916c3b1290994060d89df7acb1b984f86c2c80c2596ce037b927e7f1d66ffd2ca8a3a706a4e112141de
6
+ metadata.gz: d258aaa70f61c283fde88bff75649f799e3be874f5535d5dc292785598a15e5540a3c15a5110b9517b294d6c801725a9102575b26651e11df7a37d267edfb50f
7
+ data.tar.gz: 3155c759ec706520684d4939be31470b1fe8da68252bab072dbbf6b0449bdc9eaff553568d994b8a5d3ae3841ca05edb186a61bfc7c541e8a3a1f848319b2962
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.1.0 (2024-12-28)
4
+
5
+ - Escape strings that look like Excel escape sequences (#56)
6
+
3
7
  ## 3.0.0 (2024-12-28)
4
8
 
5
9
  - Change dependency from zip\_tricks to zip\_kit (#57)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Xlsxtream
3
- VERSION = '3.0.0'
3
+ VERSION = '3.1.0'
4
4
  end
data/lib/xlsxtream/xml.rb CHANGED
@@ -8,6 +8,10 @@ module Xlsxtream
8
8
  '>' => '>',
9
9
  }.freeze
10
10
 
11
+ # Escape first underscore of ST_Xstring sequences in input strings to appear as plaintext in Excel
12
+ HEX_ESCAPE_REGEXP = /_(x[0-9A-Fa-f]{4}_)/.freeze
13
+ XML_ESCAPE_UNDERSCORE = '_x005f_\1'.freeze
14
+
11
15
  XML_DECLARATION = %'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n'.freeze
12
16
 
13
17
  WS_AROUND_TAGS = /(?<=>)\s+|\s+(?=<)/.freeze
@@ -37,7 +41,10 @@ module Xlsxtream
37
41
  end
38
42
 
39
43
  def escape_value(string)
40
- string.gsub(UNSAFE_VALUE_CHARS, XML_ESCAPES).gsub(INVALID_XML10_CHARS, &ESCAPE_CHAR)
44
+ string
45
+ .gsub(UNSAFE_VALUE_CHARS, XML_ESCAPES)
46
+ .gsub(HEX_ESCAPE_REGEXP, XML_ESCAPE_UNDERSCORE)
47
+ .gsub(INVALID_XML10_CHARS, &ESCAPE_CHAR)
41
48
  end
42
49
 
43
50
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xlsxtream
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Bünemann