rexml 3.2.6 → 3.3.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rexml might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2583ae302aa5e698f0887a689c416e5debe0533ac472a9f96fce6a8912040fd8
4
- data.tar.gz: b0ffa6301fd899969a78e060ccaeafebfc2169e3c63ff499ebc6170468866475
3
+ metadata.gz: 70ccd1465a05dba3d53dcfc4a98e76dec865a4f6ac833b954aff4234bce6c255
4
+ data.tar.gz: 53f43fab8f531e0ba7461ce091e5eae6bec27b12e9139450c7b3e748b4eeacdc
5
5
  SHA512:
6
- metadata.gz: f63fb0b84ef51e790cc6310244f2106d8c47ec9a00687c58c743afda82b60be9986d503c6f56f947db06f6758707facccd03405c4d1009376e856080aa26d0e4
7
- data.tar.gz: db62bea7391837a7ab4cfc5cb5a412ed4deb8d232653ca66d93a323a5a76383eed520cd4ced5b20204f29b04e84678791cd6f807195868f5d4a5e519a73d2aaf
6
+ metadata.gz: b46818d79ae57075c4e0bd620802e82c6958dddc7da1b182504c3fdc16685c887ac0ddd6a4838a080483abba330839e9ef4b2db22cc81b9eae3eac71ac14c965
7
+ data.tar.gz: 1e5205905eb435c02038dd0539de22472f5364ffc47635f13a1752cb79a423dcca558fb47394ac5d624b358e779b07cbcafedfd06b99742026856f9988109976
data/NEWS.md CHANGED
@@ -1,5 +1,204 @@
1
1
  # News
2
2
 
3
+ ## 3.3.2 - 2024-07-16 {#version-3-3-2}
4
+
5
+ ### Improvements
6
+
7
+ * Improved parse performance.
8
+ * GH-160
9
+ * Patch by NAITOH Jun.
10
+
11
+ * Improved parse performance.
12
+ * GH-169
13
+ * GH-170
14
+ * GH-171
15
+ * GH-172
16
+ * GH-173
17
+ * GH-174
18
+ * Patch by Watson.
19
+
20
+ * Added support for raising a parse exception when an XML has extra
21
+ content after the root element.
22
+ * GH-161
23
+ * Patch by NAITOH Jun.
24
+
25
+ * Added support for raising a parse exception when an XML
26
+ declaration exists in wrong position.
27
+ * GH-162
28
+ * Patch by NAITOH Jun.
29
+
30
+ * Removed needless a space after XML declaration in pretty print mode.
31
+ * GH-164
32
+ * Patch by NAITOH Jun.
33
+
34
+ * Stopped to emit `:text` event after the root element.
35
+ * GH-167
36
+ * Patch by NAITOH Jun.
37
+
38
+ ### Fixes
39
+
40
+ * Fixed a bug that SAX2 parser doesn't expand predefined entities for
41
+ `characters` callback.
42
+ * GH-168
43
+ * Patch by NAITOH Jun.
44
+
45
+ ### Thanks
46
+
47
+ * NAITOH Jun
48
+
49
+ * Watson
50
+
51
+ ## 3.3.1 - 2024-06-25 {#version-3-3-1}
52
+
53
+ ### Improvements
54
+
55
+ * Added support for detecting malformed top-level comments.
56
+ * GH-145
57
+ * Patch by Hiroya Fujinami.
58
+
59
+ * Improved `REXML::Element#attribute` performance.
60
+ * GH-146
61
+ * Patch by Hiroya Fujinami.
62
+
63
+ * Added support for detecting malformed `<!-->` comments.
64
+ * GH-147
65
+ * Patch by Hiroya Fujinami.
66
+
67
+ * Added support for detecting unclosed `DOCTYPE`.
68
+ * GH-152
69
+ * Patch by Hiroya Fujinami.
70
+
71
+ * Added `changlog_uri` metadata to gemspec.
72
+ * GH-156
73
+ * Patch by fynsta.
74
+
75
+ * Improved parse performance.
76
+ * GH-157
77
+ * GH-158
78
+ * Patch by NAITOH Jun.
79
+
80
+ ### Fixes
81
+
82
+ * Fixed a bug that large XML can't be parsed.
83
+ * GH-154
84
+ * Patch by NAITOH Jun.
85
+
86
+ * Fixed a bug that private constants are visible.
87
+ * GH-155
88
+ * Patch by NAITOH Jun.
89
+
90
+ ### Thanks
91
+
92
+ * Hiroya Fujinami
93
+
94
+ * NAITOH Jun
95
+
96
+ * fynsta
97
+
98
+ ## 3.3.0 - 2024-06-11 {#version-3-3-0}
99
+
100
+ ### Improvements
101
+
102
+ * Added support for strscan 0.7.0 installed with Ruby 2.6.
103
+ * GH-142
104
+ * Reported by Fernando Trigoso.
105
+
106
+ ### Thanks
107
+
108
+ * Fernando Trigoso
109
+
110
+ ## 3.2.9 - 2024-06-09 {#version-3-2-9}
111
+
112
+ ### Improvements
113
+
114
+ * Added support for old strscan.
115
+ * GH-132
116
+ * Reported by Adam.
117
+
118
+ * Improved attribute value parse performance.
119
+ * GH-135
120
+ * Patch by NAITOH Jun.
121
+
122
+ * Improved `REXML::Node#each_recursive` performance.
123
+ * GH-134
124
+ * GH-139
125
+ * Patch by Hiroya Fujinami.
126
+
127
+ * Improved text parse performance.
128
+ * Reported by mprogrammer.
129
+
130
+ ### Thanks
131
+
132
+ * Adam
133
+ * NAITOH Jun
134
+ * Hiroya Fujinami
135
+ * mprogrammer
136
+
137
+ ## 3.2.8 - 2024-05-16 {#version-3-2-8}
138
+
139
+ ### Fixes
140
+
141
+ * Suppressed a warning
142
+
143
+ ## 3.2.7 - 2024-05-16 {#version-3-2-7}
144
+
145
+ ### Improvements
146
+
147
+ * Improve parse performance by using `StringScanner`.
148
+
149
+ * GH-106
150
+ * GH-107
151
+ * GH-108
152
+ * GH-109
153
+ * GH-112
154
+ * GH-113
155
+ * GH-114
156
+ * GH-115
157
+ * GH-116
158
+ * GH-117
159
+ * GH-118
160
+ * GH-119
161
+ * GH-121
162
+
163
+ * Patch by NAITOH Jun.
164
+
165
+ * Improved parse performance when an attribute has many `<`s.
166
+
167
+ * GH-126
168
+
169
+ ### Fixes
170
+
171
+ * XPath: Fixed a bug of `normalize_space(array)`.
172
+
173
+ * GH-110
174
+ * GH-111
175
+
176
+ * Patch by flatisland.
177
+
178
+ * XPath: Fixed a bug that wrong position is used with nested path.
179
+
180
+ * GH-110
181
+ * GH-122
182
+
183
+ * Reported by jcavalieri.
184
+ * Patch by NAITOH Jun.
185
+
186
+ * Fixed a bug that an exception message can't be generated for
187
+ invalid encoding XML.
188
+
189
+ * GH-29
190
+ * GH-123
191
+
192
+ * Reported by DuKewu.
193
+ * Patch by NAITOH Jun.
194
+
195
+ ### Thanks
196
+
197
+ * NAITOH Jun
198
+ * flatisland
199
+ * jcavalieri
200
+ * DuKewu
201
+
3
202
  ## 3.2.6 - 2023-07-27 {#version-3-2-6}
4
203
 
5
204
  ### Improvements
data/lib/rexml/element.rb CHANGED
@@ -7,14 +7,6 @@ require_relative "xpath"
7
7
  require_relative "parseexception"
8
8
 
9
9
  module REXML
10
- # An implementation note about namespaces:
11
- # As we parse, when we find namespaces we put them in a hash and assign
12
- # them a unique ID. We then convert the namespace prefix for the node
13
- # to the unique ID. This makes namespace lookup much faster for the
14
- # cost of extra memory use. We save the namespace prefix for the
15
- # context node and convert it back when we write it.
16
- @@namespaces = {}
17
-
18
10
  # An \REXML::Element object represents an XML element.
19
11
  #
20
12
  # An element:
@@ -1284,16 +1276,11 @@ module REXML
1284
1276
  # document.root.attribute("x", "a") # => a:x='a:x'
1285
1277
  #
1286
1278
  def attribute( name, namespace=nil )
1287
- prefix = nil
1288
- if namespaces.respond_to? :key
1289
- prefix = namespaces.key(namespace) if namespace
1290
- else
1291
- prefix = namespaces.index(namespace) if namespace
1292
- end
1279
+ prefix = namespaces.key(namespace) if namespace
1293
1280
  prefix = nil if prefix == 'xmlns'
1294
1281
 
1295
1282
  ret_val =
1296
- attributes.get_attribute( "#{prefix ? prefix + ':' : ''}#{name}" )
1283
+ attributes.get_attribute( prefix ? "#{prefix}:#{name}" : name )
1297
1284
 
1298
1285
  return ret_val unless ret_val.nil?
1299
1286
  return nil if prefix.nil?
@@ -111,7 +111,7 @@ module REXML
111
111
  # itself, then we don't need a carriage return... which makes this
112
112
  # logic more complex.
113
113
  node.children.each { |child|
114
- next if child == node.children[-1] and child.instance_of?(Text)
114
+ next if child.instance_of?(Text)
115
115
  unless child == node.children[0] or child.instance_of?(Text) or
116
116
  (child == node.children[1] and !node.children[0].writethis)
117
117
  output << "\n"
@@ -262,11 +262,10 @@ module REXML
262
262
  string(string).length
263
263
  end
264
264
 
265
- # UNTESTED
266
265
  def Functions::normalize_space( string=nil )
267
266
  string = string(@@context[:node]) if string.nil?
268
267
  if string.kind_of? Array
269
- string.collect{|x| string.to_s.strip.gsub(/\s+/um, ' ') if string}
268
+ string.collect{|x| x.to_s.strip.gsub(/\s+/um, ' ') if x}
270
269
  else
271
270
  string.to_s.strip.gsub(/\s+/um, ' ')
272
271
  end
data/lib/rexml/node.rb CHANGED
@@ -52,10 +52,14 @@ module REXML
52
52
 
53
53
  # Visit all subnodes of +self+ recursively
54
54
  def each_recursive(&block) # :yields: node
55
- self.elements.each {|node|
56
- block.call(node)
57
- node.each_recursive(&block)
58
- }
55
+ stack = []
56
+ each { |child| stack.unshift child if child.node_type == :element }
57
+ until stack.empty?
58
+ child = stack.pop
59
+ yield child
60
+ n = stack.size
61
+ child.each { |grandchild| stack.insert n, grandchild if grandchild.node_type == :element }
62
+ end
59
63
  end
60
64
 
61
65
  # Find (and return) first subnode (recursively) for which the block
@@ -29,6 +29,7 @@ module REXML
29
29
  err << "\nLine: #{line}\n"
30
30
  err << "Position: #{position}\n"
31
31
  err << "Last 80 unconsumed characters:\n"
32
+ err.force_encoding("ASCII-8BIT")
32
33
  err << @source.buffer[0..80].force_encoding("ASCII-8BIT").gsub(/\n/, ' ')
33
34
  end
34
35