rexml 3.2.6 → 3.4.2

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: 2583ae302aa5e698f0887a689c416e5debe0533ac472a9f96fce6a8912040fd8
4
- data.tar.gz: b0ffa6301fd899969a78e060ccaeafebfc2169e3c63ff499ebc6170468866475
3
+ metadata.gz: 75f7d0bba9d8346e2374abacaf7aea57044c66f368a695521bc16f6b07e31eaf
4
+ data.tar.gz: 674cf531dbe9684f3cc9945255aec412d0b80ae0117da3c57552c5ae3bbc66a1
5
5
  SHA512:
6
- metadata.gz: f63fb0b84ef51e790cc6310244f2106d8c47ec9a00687c58c743afda82b60be9986d503c6f56f947db06f6758707facccd03405c4d1009376e856080aa26d0e4
7
- data.tar.gz: db62bea7391837a7ab4cfc5cb5a412ed4deb8d232653ca66d93a323a5a76383eed520cd4ced5b20204f29b04e84678791cd6f807195868f5d4a5e519a73d2aaf
6
+ metadata.gz: c36c00f2e2c0ed931c85a0e0fb7720771d314f93fa1e66e1057b4e8fb7fe1d1bd3f50debdfa05587e511f1cad8d7345aa8066b18392554da6e8f6baad6a3b9d7
7
+ data.tar.gz: dc53db592782ad36f083493b8864d49872b8c989b9e2f5d9a1811d56fae3100cf2cad27bb4ab81b9d308715da523d0a4f71d4e236e5847d540d0e92a85c1bd20
data/NEWS.md CHANGED
@@ -1,5 +1,530 @@
1
1
  # News
2
2
 
3
+ ## 3.4.2 - 2025-08-26 {#version-3-4-2}
4
+
5
+ ### Improvement
6
+
7
+ * Improved performance.
8
+ * GH-244
9
+ * GH-245
10
+ * GH-246
11
+ * GH-249
12
+ * GH-256
13
+ * Patch by NAITOH Jun
14
+
15
+ * Raise appropriate exception when failing to match start tag in DOCTYPE
16
+ * GH-247
17
+ * Patch by NAITOH Jun
18
+
19
+ * Deprecate accepting array as an element in XPath.match, first and each
20
+ * GH-252
21
+ * Patch by tomoya ishida
22
+
23
+ * Don't call needless encoding_updated
24
+ * GH-259
25
+ * Patch by Sutou Kouhei
26
+
27
+ * Reuse XPath::match
28
+ * GH-263
29
+ * Patch by pboling
30
+
31
+ * Cache redundant calls for doctype
32
+ * GH-264
33
+ * Patch by pboling
34
+
35
+ * Use Safe Navigation (&.) from Ruby 2.3
36
+ * GH-265
37
+ * Patch by pboling
38
+
39
+ * Remove redundant return statements
40
+ * GH-266
41
+ * Patch by pboling
42
+
43
+ * Added XML declaration check & Source#skip_spaces method
44
+ * GH-282
45
+ * Patch by NAITOH Jun
46
+ * Reported by Sofi Aberegg
47
+
48
+ ### Fixes
49
+
50
+ * Fix docs typo
51
+ * GH-248
52
+ * Patch by James Coleman
53
+
54
+ * Fix reverse sort in xpath_parser
55
+ * GH-251
56
+ * Patch by tomoya ishida
57
+
58
+ * Fix duplicate responses in XPath following, following-sibling, preceding, preceding-sibling
59
+ * GH-255
60
+ * Patch by NAITOH Jun
61
+
62
+ * Fix wrong Encoding resolution
63
+ * GH-258
64
+ * Patch by Sutou Kouhei
65
+
66
+ * Handle nil when parsing fragment
67
+ * GH-267
68
+ * GH-268
69
+ * Patch by pboling
70
+
71
+ * [Documentation] Use # to reference instance methods
72
+ * GH-269
73
+ * GH-270
74
+ * Patch by pboling
75
+
76
+ * Fix & Deprecate REXML::Text#text_indent
77
+ * GH-273
78
+ * GH-275
79
+ * Patch by pboling
80
+
81
+ * remove bundler from dev deps
82
+ * GH-276
83
+ * GH-277
84
+ * Patch by pboling
85
+
86
+ * remove ostruct from dev deps
87
+ * GH-280
88
+ * GH-281
89
+ * Patch by pboling
90
+
91
+ ### Thanks
92
+
93
+ * NAITOH Jun
94
+
95
+ * tomoya ishida
96
+
97
+ * James Coleman
98
+
99
+ * pboling
100
+
101
+ * Sutou Kouhei
102
+
103
+ * Sofi Aberegg
104
+
105
+ ## 3.4.1 - 2025-02-16 {#version-3-4-1}
106
+
107
+ ### Improvement
108
+
109
+ * Improved performance.
110
+ * GH-226
111
+ * GH-227
112
+ * GH-237
113
+ * Patch by NAITOH Jun
114
+
115
+ ### Fixes
116
+
117
+ * Fix serialization of ATTLIST is incorrect
118
+ * GH-233
119
+ * GH-234
120
+ * Patch by OlofKalufs
121
+ * Reported by OlofKalufs
122
+
123
+ ### Thanks
124
+
125
+ * NAITOH Jun
126
+
127
+ * OlofKalufs
128
+
129
+ ## 3.4.0 - 2024-12-15 {#version-3-4-0}
130
+
131
+ ### Improvement
132
+
133
+ * Improved performance.
134
+ * GH-216
135
+ * Patch by NAITOH Jun
136
+
137
+ * JRuby: Improved parse performance.
138
+ * GH-219
139
+ * Patch by João Duarte
140
+
141
+ * Added support for reusing pull parser.
142
+ * GH-214
143
+ * GH-220
144
+ * Patch by Dmitry Pogrebnoy
145
+
146
+ * Improved error handling when source is `IO`.
147
+ * GH-221
148
+ * Patch by NAITOH Jun
149
+
150
+ ### Thanks
151
+
152
+ * NAITOH Jun
153
+
154
+ * João Duarte
155
+
156
+ * Dmitry Pogrebnoy
157
+
158
+ ## 3.3.9 - 2024-10-24 {#version-3-3-9}
159
+
160
+ ### Improvements
161
+
162
+ * Improved performance.
163
+ * GH-210
164
+ * Patch by NAITOH Jun.
165
+
166
+ ### Fixes
167
+
168
+ * Fixed a parse bug for text only invalid XML.
169
+ * GH-215
170
+ * Patch by NAITOH Jun.
171
+
172
+ * Fixed a parse bug that `&#0x...;` is accepted as a character
173
+ reference.
174
+
175
+ ### Thanks
176
+
177
+ * NAITOH Jun
178
+
179
+ ## 3.3.8 - 2024-09-29 {#version-3-3-8}
180
+
181
+ ### Improvements
182
+
183
+ * SAX2: Improve parse performance.
184
+ * GH-207
185
+ * Patch by NAITOH Jun.
186
+
187
+ ### Fixes
188
+
189
+ * Fixed a bug that unexpected attribute namespace conflict error for
190
+ the predefined "xml" namespace is reported.
191
+ * GH-208
192
+ * Patch by KITAITI Makoto
193
+
194
+ ### Thanks
195
+
196
+ * NAITOH Jun
197
+
198
+ * KITAITI Makoto
199
+
200
+ ## 3.3.7 - 2024-09-04 {#version-3-3-7}
201
+
202
+ ### Improvements
203
+
204
+ * Added local entity expansion limit methods
205
+ * GH-192
206
+ * GH-202
207
+ * Reported by takuya kodama.
208
+ * Patch by NAITOH Jun.
209
+
210
+ * Removed explicit strscan dependency
211
+ * GH-204
212
+ * Patch by Bo Anderson.
213
+
214
+ ### Thanks
215
+
216
+ * takuya kodama
217
+
218
+ * NAITOH Jun
219
+
220
+ * Bo Anderson
221
+
222
+ ## 3.3.6 - 2024-08-22 {#version-3-3-6}
223
+
224
+ ### Improvements
225
+
226
+ * Removed duplicated entity expansions for performance.
227
+ * GH-194
228
+ * Patch by Viktor Ivarsson.
229
+
230
+ * Improved namespace conflicted attribute check performance. It was
231
+ too slow for deep elements.
232
+ * Reported by l33thaxor.
233
+
234
+ ### Fixes
235
+
236
+ * Fixed a bug that default entity expansions are counted for
237
+ security check. Default entity expansions should not be counted
238
+ because they don't have a security risk.
239
+ * GH-198
240
+ * GH-199
241
+ * Patch Viktor Ivarsson
242
+
243
+ * Fixed a parser bug that parameter entity references in internal
244
+ subsets are expanded. It's not allowed in the XML specification.
245
+ * GH-191
246
+ * Patch by NAITOH Jun.
247
+
248
+ * Fixed a stream parser bug that user-defined entity references in
249
+ text aren't expanded.
250
+ * GH-200
251
+ * Patch by NAITOH Jun.
252
+
253
+ ### Thanks
254
+
255
+ * Viktor Ivarsson
256
+
257
+ * NAITOH Jun
258
+
259
+ * l33thaxor
260
+
261
+ ## 3.3.5 - 2024-08-12 {#version-3-3-5}
262
+
263
+ ### Fixes
264
+
265
+ * Fixed a bug that `REXML::Security.entity_expansion_text_limit`
266
+ check has wrong text size calculation in SAX and pull parsers.
267
+ * GH-193
268
+ * GH-195
269
+ * Reported by Viktor Ivarsson.
270
+ * Patch by NAITOH Jun.
271
+
272
+ ### Thanks
273
+
274
+ * Viktor Ivarsson
275
+
276
+ * NAITOH Jun
277
+
278
+ ## 3.3.4 - 2024-08-01 {#version-3-3-4}
279
+
280
+ ### Fixes
281
+
282
+ * Fixed a bug that `REXML::Security` isn't defined when
283
+ `REXML::Parsers::StreamParser` is used and
284
+ `rexml/parsers/streamparser` is only required.
285
+ * GH-189
286
+ * Patch by takuya kodama.
287
+
288
+ ### Thanks
289
+
290
+ * takuya kodama
291
+
292
+ ## 3.3.3 - 2024-08-01 {#version-3-3-3}
293
+
294
+ ### Improvements
295
+
296
+ * Added support for detecting invalid XML that has unsupported
297
+ content before root element
298
+ * GH-184
299
+ * Patch by NAITOH Jun.
300
+
301
+ * Added support for `REXML::Security.entity_expansion_limit=` and
302
+ `REXML::Security.entity_expansion_text_limit=` in SAX2 and pull
303
+ parsers
304
+ * GH-187
305
+ * Patch by NAITOH Jun.
306
+
307
+ * Added more tests for invalid XMLs.
308
+ * GH-183
309
+ * Patch by Watson.
310
+
311
+ * Added more performance tests.
312
+ * Patch by Watson.
313
+
314
+ * Improved parse performance.
315
+ * GH-186
316
+ * Patch by tomoya ishida.
317
+
318
+ ### Thanks
319
+
320
+ * NAITOH Jun
321
+
322
+ * Watson
323
+
324
+ * tomoya ishida
325
+
326
+ ## 3.3.2 - 2024-07-16 {#version-3-3-2}
327
+
328
+ ### Improvements
329
+
330
+ * Improved parse performance.
331
+ * GH-160
332
+ * Patch by NAITOH Jun.
333
+
334
+ * Improved parse performance.
335
+ * GH-169
336
+ * GH-170
337
+ * GH-171
338
+ * GH-172
339
+ * GH-173
340
+ * GH-174
341
+ * GH-175
342
+ * GH-176
343
+ * GH-177
344
+ * Patch by Watson.
345
+
346
+ * Added support for raising a parse exception when an XML has extra
347
+ content after the root element.
348
+ * GH-161
349
+ * Patch by NAITOH Jun.
350
+
351
+ * Added support for raising a parse exception when an XML
352
+ declaration exists in wrong position.
353
+ * GH-162
354
+ * Patch by NAITOH Jun.
355
+
356
+ * Removed needless a space after XML declaration in pretty print mode.
357
+ * GH-164
358
+ * Patch by NAITOH Jun.
359
+
360
+ * Stopped to emit `:text` event after the root element.
361
+ * GH-167
362
+ * Patch by NAITOH Jun.
363
+
364
+ ### Fixes
365
+
366
+ * Fixed a bug that SAX2 parser doesn't expand predefined entities for
367
+ `characters` callback.
368
+ * GH-168
369
+ * Patch by NAITOH Jun.
370
+
371
+ ### Thanks
372
+
373
+ * NAITOH Jun
374
+
375
+ * Watson
376
+
377
+ ## 3.3.1 - 2024-06-25 {#version-3-3-1}
378
+
379
+ ### Improvements
380
+
381
+ * Added support for detecting malformed top-level comments.
382
+ * GH-145
383
+ * Patch by Hiroya Fujinami.
384
+
385
+ * Improved `REXML::Element#attribute` performance.
386
+ * GH-146
387
+ * Patch by Hiroya Fujinami.
388
+
389
+ * Added support for detecting malformed `<!-->` comments.
390
+ * GH-147
391
+ * Patch by Hiroya Fujinami.
392
+
393
+ * Added support for detecting unclosed `DOCTYPE`.
394
+ * GH-152
395
+ * Patch by Hiroya Fujinami.
396
+
397
+ * Added `changlog_uri` metadata to gemspec.
398
+ * GH-156
399
+ * Patch by fynsta.
400
+
401
+ * Improved parse performance.
402
+ * GH-157
403
+ * GH-158
404
+ * Patch by NAITOH Jun.
405
+
406
+ ### Fixes
407
+
408
+ * Fixed a bug that large XML can't be parsed.
409
+ * GH-154
410
+ * Patch by NAITOH Jun.
411
+
412
+ * Fixed a bug that private constants are visible.
413
+ * GH-155
414
+ * Patch by NAITOH Jun.
415
+
416
+ ### Thanks
417
+
418
+ * Hiroya Fujinami
419
+
420
+ * NAITOH Jun
421
+
422
+ * fynsta
423
+
424
+ ## 3.3.0 - 2024-06-11 {#version-3-3-0}
425
+
426
+ ### Improvements
427
+
428
+ * Added support for strscan 0.7.0 installed with Ruby 2.6.
429
+ * GH-142
430
+ * Reported by Fernando Trigoso.
431
+
432
+ ### Thanks
433
+
434
+ * Fernando Trigoso
435
+
436
+ ## 3.2.9 - 2024-06-09 {#version-3-2-9}
437
+
438
+ ### Improvements
439
+
440
+ * Added support for old strscan.
441
+ * GH-132
442
+ * Reported by Adam.
443
+
444
+ * Improved attribute value parse performance.
445
+ * GH-135
446
+ * Patch by NAITOH Jun.
447
+
448
+ * Improved `REXML::Node#each_recursive` performance.
449
+ * GH-134
450
+ * GH-139
451
+ * Patch by Hiroya Fujinami.
452
+
453
+ * Improved text parse performance.
454
+ * Reported by mprogrammer.
455
+
456
+ ### Thanks
457
+
458
+ * Adam
459
+ * NAITOH Jun
460
+ * Hiroya Fujinami
461
+ * mprogrammer
462
+
463
+ ## 3.2.8 - 2024-05-16 {#version-3-2-8}
464
+
465
+ ### Fixes
466
+
467
+ * Suppressed a warning
468
+
469
+ ## 3.2.7 - 2024-05-16 {#version-3-2-7}
470
+
471
+ ### Improvements
472
+
473
+ * Improve parse performance by using `StringScanner`.
474
+
475
+ * GH-106
476
+ * GH-107
477
+ * GH-108
478
+ * GH-109
479
+ * GH-112
480
+ * GH-113
481
+ * GH-114
482
+ * GH-115
483
+ * GH-116
484
+ * GH-117
485
+ * GH-118
486
+ * GH-119
487
+ * GH-121
488
+
489
+ * Patch by NAITOH Jun.
490
+
491
+ * Improved parse performance when an attribute has many `>`s.
492
+
493
+ * GH-126
494
+
495
+ ### Fixes
496
+
497
+ * XPath: Fixed a bug of `normalize_space(array)`.
498
+
499
+ * GH-110
500
+ * GH-111
501
+
502
+ * Patch by flatisland.
503
+
504
+ * XPath: Fixed a bug that wrong position is used with nested path.
505
+
506
+ * GH-110
507
+ * GH-122
508
+
509
+ * Reported by jcavalieri.
510
+ * Patch by NAITOH Jun.
511
+
512
+ * Fixed a bug that an exception message can't be generated for
513
+ invalid encoding XML.
514
+
515
+ * GH-29
516
+ * GH-123
517
+
518
+ * Reported by DuKewu.
519
+ * Patch by NAITOH Jun.
520
+
521
+ ### Thanks
522
+
523
+ * NAITOH Jun
524
+ * flatisland
525
+ * jcavalieri
526
+ * DuKewu
527
+
3
528
  ## 3.2.6 - 2023-07-27 {#version-3-2-6}
4
529
 
5
530
  ### Improvements
@@ -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
@@ -148,8 +145,9 @@ module REXML
148
145
  # have been expanded to their values
149
146
  def value
150
147
  return @unnormalized if @unnormalized
151
- @unnormalized = Text::unnormalize( @normalized, doctype )
152
- @unnormalized
148
+
149
+ @unnormalized = Text::unnormalize(@normalized, doctype,
150
+ entity_expansion_text_limit: @element&.document&.entity_expansion_text_limit)
153
151
  end
154
152
 
155
153
  # The normalized value of this attribute. That is, the attribute with
@@ -172,7 +170,7 @@ module REXML
172
170
  @element = element
173
171
 
174
172
  if @normalized
175
- Text.check( @normalized, NEEDS_A_SECOND_CHECK, doctype )
173
+ Text.check( @normalized, NEEDS_A_SECOND_CHECK )
176
174
  end
177
175
 
178
176
  self
@@ -201,9 +199,11 @@ module REXML
201
199
  end
202
200
 
203
201
  def xpath
204
- path = @element.xpath
205
- path += "/@#{self.expanded_name}"
206
- return path
202
+ @element.xpath + "/@#{self.expanded_name}"
203
+ end
204
+
205
+ def document
206
+ @element&.document
207
207
  end
208
208
  end
209
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)
@@ -91,6 +91,8 @@ module REXML
91
91
  #
92
92
  def initialize( source = nil, context = {} )
93
93
  @entity_expansion_count = 0
94
+ @entity_expansion_limit = Security.entity_expansion_limit
95
+ @entity_expansion_text_limit = Security.entity_expansion_text_limit
94
96
  super()
95
97
  @context = context
96
98
  return if source.nil?
@@ -307,8 +309,8 @@ module REXML
307
309
  end
308
310
 
309
311
  # :call-seq:
310
- # doc.write(output=$stdout, indent=-1, transtive=false, ie_hack=false, encoding=nil)
311
- # doc.write(options={:output => $stdout, :indent => -1, :transtive => false, :ie_hack => false, :encoding => nil})
312
+ # doc.write(output=$stdout, indent=-1, transitive=false, ie_hack=false, encoding=nil)
313
+ # doc.write(options={:output => $stdout, :indent => -1, :transitive => false, :ie_hack => false, :encoding => nil})
312
314
  #
313
315
  # Write the XML tree out, optionally with indent. This writes out the
314
316
  # entire XML document, including XML declarations, doctype declarations,
@@ -413,7 +415,7 @@ module REXML
413
415
  #
414
416
  # Deprecated. Use REXML::Security.entity_expansion_limit= instead.
415
417
  def Document::entity_expansion_limit
416
- return Security.entity_expansion_limit
418
+ Security.entity_expansion_limit
417
419
  end
418
420
 
419
421
  # Set the entity expansion limit. By default the limit is set to 10240.
@@ -427,14 +429,16 @@ module REXML
427
429
  #
428
430
  # Deprecated. Use REXML::Security.entity_expansion_text_limit instead.
429
431
  def Document::entity_expansion_text_limit
430
- return Security.entity_expansion_text_limit
432
+ Security.entity_expansion_text_limit
431
433
  end
432
434
 
433
435
  attr_reader :entity_expansion_count
436
+ attr_writer :entity_expansion_limit
437
+ attr_accessor :entity_expansion_text_limit
434
438
 
435
439
  def record_entity_expansion
436
440
  @entity_expansion_count += 1
437
- if @entity_expansion_count > Security.entity_expansion_limit
441
+ if @entity_expansion_count > @entity_expansion_limit
438
442
  raise "number of entity expansions exceeded, processing aborted."
439
443
  end
440
444
  end
@@ -444,6 +448,20 @@ module REXML
444
448
  end
445
449
 
446
450
  private
451
+
452
+ attr_accessor :namespaces_cache
453
+
454
+ # New document level cache is created and available in this block.
455
+ # This API is thread unsafe. Users can't change this document in this block.
456
+ def enable_cache
457
+ @namespaces_cache = {}
458
+ begin
459
+ yield
460
+ ensure
461
+ @namespaces_cache = nil
462
+ end
463
+ end
464
+
447
465
  def build( source )
448
466
  Parsers::TreeParser.new( source, self ).parse
449
467
  end