rexml 3.3.7 → 3.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a402bb00d8bf352521fb6ca5354ba92a22d110feedcba40a50e2de5abad277a
4
- data.tar.gz: 51f7b5893eef8d8183eb14c719064368029b18c9909b3454047e308c7425ce5b
3
+ metadata.gz: 9ac95f1cecaf1fba6908b5cab0c3c41ec38df0744658888f783d02cdf64f12f2
4
+ data.tar.gz: cbfd7145ac0dd44987e9980ee96dd2bb42360b112ac0d5b09314c4fecb46fe99
5
5
  SHA512:
6
- metadata.gz: ff091fe421748562931d65301e66dc1d4d313e1c28cce753bc9f31a1f9bac65c0b4939db70117e47f2c3158daa24b708e2519a98a9638114f4e5a1c0d1265e7c
7
- data.tar.gz: 720bc72a86eacebbe9a990152d4d0dfcde2e50c71b3fbabaaba44dec91b2f6ff7ca6180b86622cf0ffb36355ab5e5d43f8948e67c70ab4fca1f8bf0882a3585d
6
+ metadata.gz: eef25a3cdfb1f408f2fe061168d907b97c13d82ca077a731eff284868164de16991ca779ab30e10050d67df0518eaf334add57b78998add1d108eae597001dc6
7
+ data.tar.gz: 2ec4a1b379e2f0e15c9161e929c9846aad47635b6a6705e8ae4bd985b8a8037b5f213e043d7811ce0530b7601d35e499006fe65911fcfdcdad089f6cbc7c0e72
data/NEWS.md CHANGED
@@ -1,5 +1,244 @@
1
1
  # News
2
2
 
3
+ ## 3.4.4 - 2025-09-10 {#version-3-4-4}
4
+
5
+ ### Improvement
6
+
7
+ * Accept `REXML::Document.new("")` for backward compatibility
8
+ * GH-296
9
+ * GH-295
10
+ * Patch by NAITOH Jun
11
+ * Reported by Joe Rafaniello
12
+
13
+ ### Thanks
14
+
15
+ * NAITOH Jun
16
+
17
+ * Joe Rafaniello
18
+
19
+ ## 3.4.3 - 2025-09-07 {#version-3-4-3}
20
+
21
+ ### Improvement
22
+
23
+ * Reject no root element XML as an invalid XML
24
+ * GH-289
25
+ * GH-291
26
+ * Patch by NAITOH Jun
27
+ * Reported by Sutou Kouhei
28
+
29
+ ### Fixes
30
+
31
+ * Fixed an issue with `IOSource#read_until` when reaching the end of a file
32
+ * GH-287
33
+ * GH-288
34
+ * Patch by NAITOH Jun
35
+ * Reported by Jason Thomas
36
+
37
+ ### Thanks
38
+
39
+ * NAITOH Jun
40
+
41
+ * Sutou Kouhei
42
+
43
+ * Jason Thomas
44
+
45
+ ## 3.4.2 - 2025-08-26 {#version-3-4-2}
46
+
47
+ ### Improvement
48
+
49
+ * Improved performance.
50
+ * GH-244
51
+ * GH-245
52
+ * GH-246
53
+ * GH-249
54
+ * GH-256
55
+ * Patch by NAITOH Jun
56
+
57
+ * Raise appropriate exception when failing to match start tag in DOCTYPE
58
+ * GH-247
59
+ * Patch by NAITOH Jun
60
+
61
+ * Deprecate accepting array as an element in XPath.match, first and each
62
+ * GH-252
63
+ * Patch by tomoya ishida
64
+
65
+ * Don't call needless encoding_updated
66
+ * GH-259
67
+ * Patch by Sutou Kouhei
68
+
69
+ * Reuse XPath::match
70
+ * GH-263
71
+ * Patch by pboling
72
+
73
+ * Cache redundant calls for doctype
74
+ * GH-264
75
+ * Patch by pboling
76
+
77
+ * Use Safe Navigation (&.) from Ruby 2.3
78
+ * GH-265
79
+ * Patch by pboling
80
+
81
+ * Remove redundant return statements
82
+ * GH-266
83
+ * Patch by pboling
84
+
85
+ * Added XML declaration check & Source#skip_spaces method
86
+ * GH-282
87
+ * Patch by NAITOH Jun
88
+ * Reported by Sofi Aberegg
89
+
90
+ ### Fixes
91
+
92
+ * Fix docs typo
93
+ * GH-248
94
+ * Patch by James Coleman
95
+
96
+ * Fix reverse sort in xpath_parser
97
+ * GH-251
98
+ * Patch by tomoya ishida
99
+
100
+ * Fix duplicate responses in XPath following, following-sibling, preceding, preceding-sibling
101
+ * GH-255
102
+ * Patch by NAITOH Jun
103
+
104
+ * Fix wrong Encoding resolution
105
+ * GH-258
106
+ * Patch by Sutou Kouhei
107
+
108
+ * Handle nil when parsing fragment
109
+ * GH-267
110
+ * GH-268
111
+ * Patch by pboling
112
+
113
+ * [Documentation] Use # to reference instance methods
114
+ * GH-269
115
+ * GH-270
116
+ * Patch by pboling
117
+
118
+ * Fix & Deprecate REXML::Text#text_indent
119
+ * GH-273
120
+ * GH-275
121
+ * Patch by pboling
122
+
123
+ * remove bundler from dev deps
124
+ * GH-276
125
+ * GH-277
126
+ * Patch by pboling
127
+
128
+ * remove ostruct from dev deps
129
+ * GH-280
130
+ * GH-281
131
+ * Patch by pboling
132
+
133
+ ### Thanks
134
+
135
+ * NAITOH Jun
136
+
137
+ * tomoya ishida
138
+
139
+ * James Coleman
140
+
141
+ * pboling
142
+
143
+ * Sutou Kouhei
144
+
145
+ * Sofi Aberegg
146
+
147
+ ## 3.4.1 - 2025-02-16 {#version-3-4-1}
148
+
149
+ ### Improvement
150
+
151
+ * Improved performance.
152
+ * GH-226
153
+ * GH-227
154
+ * GH-237
155
+ * Patch by NAITOH Jun
156
+
157
+ ### Fixes
158
+
159
+ * Fix serialization of ATTLIST is incorrect
160
+ * GH-233
161
+ * GH-234
162
+ * Patch by OlofKalufs
163
+ * Reported by OlofKalufs
164
+
165
+ ### Thanks
166
+
167
+ * NAITOH Jun
168
+
169
+ * OlofKalufs
170
+
171
+ ## 3.4.0 - 2024-12-15 {#version-3-4-0}
172
+
173
+ ### Improvement
174
+
175
+ * Improved performance.
176
+ * GH-216
177
+ * Patch by NAITOH Jun
178
+
179
+ * JRuby: Improved parse performance.
180
+ * GH-219
181
+ * Patch by João Duarte
182
+
183
+ * Added support for reusing pull parser.
184
+ * GH-214
185
+ * GH-220
186
+ * Patch by Dmitry Pogrebnoy
187
+
188
+ * Improved error handling when source is `IO`.
189
+ * GH-221
190
+ * Patch by NAITOH Jun
191
+
192
+ ### Thanks
193
+
194
+ * NAITOH Jun
195
+
196
+ * João Duarte
197
+
198
+ * Dmitry Pogrebnoy
199
+
200
+ ## 3.3.9 - 2024-10-24 {#version-3-3-9}
201
+
202
+ ### Improvements
203
+
204
+ * Improved performance.
205
+ * GH-210
206
+ * Patch by NAITOH Jun.
207
+
208
+ ### Fixes
209
+
210
+ * Fixed a parse bug for text only invalid XML.
211
+ * GH-215
212
+ * Patch by NAITOH Jun.
213
+
214
+ * Fixed a parse bug that `&#0x...;` is accepted as a character
215
+ reference.
216
+
217
+ ### Thanks
218
+
219
+ * NAITOH Jun
220
+
221
+ ## 3.3.8 - 2024-09-29 {#version-3-3-8}
222
+
223
+ ### Improvements
224
+
225
+ * SAX2: Improve parse performance.
226
+ * GH-207
227
+ * Patch by NAITOH Jun.
228
+
229
+ ### Fixes
230
+
231
+ * Fixed a bug that unexpected attribute namespace conflict error for
232
+ the predefined "xml" namespace is reported.
233
+ * GH-208
234
+ * Patch by KITAITI Makoto
235
+
236
+ ### Thanks
237
+
238
+ * NAITOH Jun
239
+
240
+ * KITAITI Makoto
241
+
3
242
  ## 3.3.7 - 2024-09-04 {#version-3-3-7}
4
243
 
5
244
  ### Improvements
@@ -291,7 +530,7 @@
291
530
 
292
531
  * Patch by NAITOH Jun.
293
532
 
294
- * Improved parse performance when an attribute has many `<`s.
533
+ * Improved parse performance when an attribute has many `>`s.
295
534
 
296
535
  * GH-126
297
536
 
@@ -130,10 +130,7 @@ module REXML
130
130
  end
131
131
 
132
132
  def doctype
133
- if @element
134
- doc = @element.document
135
- doc.doctype if doc
136
- end
133
+ @element&.document&.doctype
137
134
  end
138
135
 
139
136
  # Returns the attribute value, with entities replaced
@@ -173,7 +170,7 @@ module REXML
173
170
  @element = element
174
171
 
175
172
  if @normalized
176
- Text.check( @normalized, NEEDS_A_SECOND_CHECK, doctype )
173
+ Text.check( @normalized, NEEDS_A_SECOND_CHECK )
177
174
  end
178
175
 
179
176
  self
@@ -202,9 +199,11 @@ module REXML
202
199
  end
203
200
 
204
201
  def xpath
205
- path = @element.xpath
206
- path += "/@#{self.expanded_name}"
207
- return path
202
+ @element.xpath + "/@#{self.expanded_name}"
203
+ end
204
+
205
+ def document
206
+ @element&.document
208
207
  end
209
208
  end
210
209
  end
data/lib/rexml/cdata.rb CHANGED
@@ -58,7 +58,7 @@ module REXML
58
58
  # c = CData.new( " Some text " )
59
59
  # c.write( $stdout ) #-> <![CDATA[ Some text ]]>
60
60
  def write( output=$stdout, indent=-1, transitive=false, ie_hack=false )
61
- Kernel.warn( "#{self.class.name}.write is deprecated", uplevel: 1)
61
+ Kernel.warn( "#{self.class.name}#write is deprecated", uplevel: 1)
62
62
  indent( output, indent )
63
63
  output << START
64
64
  output << @string
data/lib/rexml/child.rb CHANGED
@@ -83,13 +83,12 @@ module REXML
83
83
  # Returns:: the document this child belongs to, or nil if this child
84
84
  # belongs to no document
85
85
  def document
86
- return parent.document unless parent.nil?
87
- nil
86
+ parent&.document
88
87
  end
89
88
 
90
89
  # This doesn't yet handle encodings
91
90
  def bytes
92
- document.encoding
91
+ document&.encoding
93
92
 
94
93
  to_s
95
94
  end
data/lib/rexml/comment.rb CHANGED
@@ -48,7 +48,7 @@ module REXML
48
48
  # ie_hack::
49
49
  # Needed for conformity to the child API, but not used by this class.
50
50
  def write( output, indent=-1, transitive=false, ie_hack=false )
51
- Kernel.warn("Comment.write is deprecated. See REXML::Formatters", uplevel: 1)
51
+ Kernel.warn("#{self.class.name}#write is deprecated. See REXML::Formatters", uplevel: 1)
52
52
  indent( output, indent )
53
53
  output << START
54
54
  output << @string
data/lib/rexml/doctype.rb CHANGED
@@ -171,15 +171,11 @@ module REXML
171
171
  end
172
172
 
173
173
  def context
174
- if @parent
175
- @parent.context
176
- else
177
- nil
178
- end
174
+ @parent&.context
179
175
  end
180
176
 
181
177
  def entity( name )
182
- @entities[name].unnormalized if @entities[name]
178
+ @entities[name]&.unnormalized
183
179
  end
184
180
 
185
181
  def add child
@@ -288,8 +284,7 @@ module REXML
288
284
  end
289
285
 
290
286
  def to_s
291
- context = nil
292
- context = parent.context if parent
287
+ context = parent&.context
293
288
  notation = "<!NOTATION #{@name}"
294
289
  reference_writer = ReferenceWriter.new(@middle, @public, @system, context)
295
290
  reference_writer.write(notation)
@@ -95,7 +95,9 @@ module REXML
95
95
  @entity_expansion_text_limit = Security.entity_expansion_text_limit
96
96
  super()
97
97
  @context = context
98
- return if source.nil?
98
+ # `source = ""` is an invalid usage because no root element XML is an invalid XML.
99
+ # But we accept `""` for backward compatibility.
100
+ return if source.nil? or source == ""
99
101
  if source.kind_of? Document
100
102
  @context = source.context
101
103
  super source
@@ -309,8 +311,8 @@ module REXML
309
311
  end
310
312
 
311
313
  # :call-seq:
312
- # doc.write(output=$stdout, indent=-1, transtive=false, ie_hack=false, encoding=nil)
313
- # doc.write(options={:output => $stdout, :indent => -1, :transtive => false, :ie_hack => false, :encoding => nil})
314
+ # doc.write(output=$stdout, indent=-1, transitive=false, ie_hack=false, encoding=nil)
315
+ # doc.write(options={:output => $stdout, :indent => -1, :transitive => false, :ie_hack => false, :encoding => nil})
314
316
  #
315
317
  # Write the XML tree out, optionally with indent. This writes out the
316
318
  # entire XML document, including XML declarations, doctype declarations,
@@ -415,7 +417,7 @@ module REXML
415
417
  #
416
418
  # Deprecated. Use REXML::Security.entity_expansion_limit= instead.
417
419
  def Document::entity_expansion_limit
418
- return Security.entity_expansion_limit
420
+ Security.entity_expansion_limit
419
421
  end
420
422
 
421
423
  # Set the entity expansion limit. By default the limit is set to 10240.
@@ -429,7 +431,7 @@ module REXML
429
431
  #
430
432
  # Deprecated. Use REXML::Security.entity_expansion_text_limit instead.
431
433
  def Document::entity_expansion_text_limit
432
- return Security.entity_expansion_text_limit
434
+ Security.entity_expansion_text_limit
433
435
  end
434
436
 
435
437
  attr_reader :entity_expansion_count
@@ -448,6 +450,20 @@ module REXML
448
450
  end
449
451
 
450
452
  private
453
+
454
+ attr_accessor :namespaces_cache
455
+
456
+ # New document level cache is created and available in this block.
457
+ # This API is thread unsafe. Users can't change this document in this block.
458
+ def enable_cache
459
+ @namespaces_cache = {}
460
+ begin
461
+ yield
462
+ ensure
463
+ @namespaces_cache = nil
464
+ end
465
+ end
466
+
451
467
  def build( source )
452
468
  Parsers::TreeParser.new( source, self ).parse
453
469
  end