rexml 3.2.8 → 3.3.0

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: cef1cb55ed6a23bce0af7d46fce791961558ee885c57f1089207deb53e18ff95
4
- data.tar.gz: 4fbe36d9e4422d266c2ffee71fab703e6408e9a2b5533ca0ae49411483f98368
3
+ metadata.gz: 25c91d880b1d9de11210a1fec235f630b6948e09104aa810b3cdde1a3d277139
4
+ data.tar.gz: b06ffa92b8f883052db3b41fcc025b9b09c0f9117c301476de0264203c94632f
5
5
  SHA512:
6
- metadata.gz: 60da703f26ff7eaa6cf537634ad68e4c3246605c26c54ea96147fae59bb6c17eeab5c234e5e67301e342472ce8dd3cb671321168cddc212839b9347c8de62f91
7
- data.tar.gz: 4d6eeaba460a22bcdc3512ac53504fe87f829cb783069fbebb989fb8f1585fbdfe9ed357c8fbda894fb68777d04f871b9073aa6d13c31eccc6b3b22db10c2ce1
6
+ metadata.gz: 21fe3b359774dd752c405d74c4888f25dfd55c436ca0f02cc34f602aff88b99f80b97cdb186bf9ccc40e52783b9f90f985d8e87fd0687972cedaf759c808cc9d
7
+ data.tar.gz: d613797dcd6f20b6c1d17deca5235a91456165fbc04dcd4fa0ec419e72bd8ba0aee7eadbb2a7e2a65263f74e0dcfacc99a9976ffe396717c2956b7f5155c2725
data/NEWS.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # News
2
2
 
3
+ ## 3.3.0 - 2024-06-11 {#version-3-3-0}
4
+
5
+ ### Improvements
6
+
7
+ * Added support for strscan 0.7.0 installed with Ruby 2.6.
8
+ * GH-142
9
+ * Reported by Fernando Trigoso.
10
+
11
+ ### Thanks
12
+
13
+ * Fernando Trigoso
14
+
15
+ ## 3.2.9 - 2024-06-09 {#version-3-2-9}
16
+
17
+ ### Improvements
18
+
19
+ * Added support for old strscan.
20
+ * GH-132
21
+ * Reported by Adam.
22
+
23
+ * Improved attribute value parse performance.
24
+ * GH-135
25
+ * Patch by NAITOH Jun.
26
+
27
+ * Improved `REXML::Node#each_recursive` performance.
28
+ * GH-134
29
+ * GH-139
30
+ * Patch by Hiroya Fujinami.
31
+
32
+ * Improved text parse performance.
33
+ * Reported by mprogrammer.
34
+
35
+ ### Thanks
36
+
37
+ * Adam
38
+ * NAITOH Jun
39
+ * Hiroya Fujinami
40
+ * mprogrammer
41
+
3
42
  ## 3.2.8 - 2024-05-16 {#version-3-2-8}
4
43
 
5
44
  ### Fixes
@@ -30,7 +69,7 @@
30
69
 
31
70
  * Improved parse performance when an attribute has many `<`s.
32
71
 
33
- * GH-124
72
+ * GH-126
34
73
 
35
74
  ### Fixes
36
75
 
@@ -65,7 +104,6 @@
65
104
  * jcavalieri
66
105
  * DuKewu
67
106
 
68
-
69
107
  ## 3.2.6 - 2023-07-27 {#version-3-2-6}
70
108
 
71
109
  ### Improvements
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
@@ -7,6 +7,17 @@ require "strscan"
7
7
 
8
8
  module REXML
9
9
  module Parsers
10
+ if StringScanner::Version < "3.0.8"
11
+ module StringScannerCaptures
12
+ refine StringScanner do
13
+ def captures
14
+ values_at(*(1...size))
15
+ end
16
+ end
17
+ end
18
+ using StringScannerCaptures
19
+ end
20
+
10
21
  # = Using the Pull Parser
11
22
  # <em>This API is experimental, and subject to change.</em>
12
23
  # parser = PullParser.new( "<a>text<b att='val'/>txet</a>" )
@@ -362,6 +373,10 @@ module REXML
362
373
  begin
363
374
  start_position = @source.position
364
375
  if @source.match("<", true)
376
+ # :text's read_until may remain only "<" in buffer. In the
377
+ # case, buffer is empty here. So we need to fill buffer
378
+ # here explicitly.
379
+ @source.ensure_buffer
365
380
  if @source.match("/", true)
366
381
  @nsstack.shift
367
382
  last_tag = @tags.pop
@@ -427,8 +442,10 @@ module REXML
427
442
  return [ :start_element, tag, attributes ]
428
443
  end
429
444
  else
430
- md = @source.match(/([^<]*)/um, true)
431
- text = md[1]
445
+ text = @source.read_until("<")
446
+ if text.chomp!("<")
447
+ @source.position -= "<".bytesize
448
+ end
432
449
  return [ :text, text ]
433
450
  end
434
451
  rescue REXML::UndefinedNamespaceException
@@ -633,8 +650,10 @@ module REXML
633
650
  raise REXML::ParseException.new(message, @source)
634
651
  end
635
652
  quote = match[1]
653
+ start_position = @source.position
636
654
  value = @source.read_until(quote)
637
655
  unless value.chomp!(quote)
656
+ @source.position = start_position
638
657
  message = "Missing attribute value end quote: <#{name}>: <#{quote}>"
639
658
  raise REXML::ParseException.new(message, @source)
640
659
  end
data/lib/rexml/rexml.rb CHANGED
@@ -31,7 +31,7 @@
31
31
  module REXML
32
32
  COPYRIGHT = "Copyright © 2001-2008 Sean Russell <ser@germane-software.com>"
33
33
  DATE = "2008/019"
34
- VERSION = "3.2.8"
34
+ VERSION = "3.3.0"
35
35
  REVISION = ""
36
36
 
37
37
  Copyright = COPYRIGHT
data/lib/rexml/source.rb CHANGED
@@ -1,8 +1,28 @@
1
1
  # coding: US-ASCII
2
2
  # frozen_string_literal: false
3
+
4
+ require "strscan"
5
+
3
6
  require_relative 'encoding'
4
7
 
5
8
  module REXML
9
+ if StringScanner::Version < "1.0.0"
10
+ module StringScannerCheckScanString
11
+ refine StringScanner do
12
+ def check(pattern)
13
+ pattern = /#{Regexp.escape(pattern)}/ if pattern.is_a?(String)
14
+ super(pattern)
15
+ end
16
+
17
+ def scan(pattern)
18
+ pattern = /#{Regexp.escape(pattern)}/ if pattern.is_a?(String)
19
+ super(pattern)
20
+ end
21
+ end
22
+ end
23
+ using StringScannerCheckScanString
24
+ end
25
+
6
26
  # Generates Source-s. USE THIS CLASS.
7
27
  class SourceFactory
8
28
  # Generates a Source object
@@ -34,6 +54,16 @@ module REXML
34
54
  attr_reader :line
35
55
  attr_reader :encoding
36
56
 
57
+ module Private
58
+ PRE_DEFINED_TERM_PATTERNS = {}
59
+ pre_defined_terms = ["'", '"', "<"]
60
+ pre_defined_terms.each do |term|
61
+ PRE_DEFINED_TERM_PATTERNS[term] = /#{Regexp.escape(term)}/
62
+ end
63
+ end
64
+ private_constant :Private
65
+ include Private
66
+
37
67
  # Constructor
38
68
  # @param arg must be a String, and should be a valid XML document
39
69
  # @param encoding if non-null, sets the encoding of the source to this
@@ -69,7 +99,13 @@ module REXML
69
99
  end
70
100
 
71
101
  def read_until(term)
72
- @scanner.scan_until(Regexp.union(term)) or @scanner.rest
102
+ pattern = Private::PRE_DEFINED_TERM_PATTERNS[term] || /#{Regexp.escape(term)}/
103
+ data = @scanner.scan_until(pattern)
104
+ unless data
105
+ data = @scanner.rest
106
+ @scanner.pos = @scanner.string.bytesize
107
+ end
108
+ data
73
109
  end
74
110
 
75
111
  def ensure_buffer
@@ -163,6 +199,7 @@ module REXML
163
199
  end
164
200
 
165
201
  def read(term = nil)
202
+ term = encode(term) if term
166
203
  begin
167
204
  @scanner << readline(term)
168
205
  true
@@ -173,16 +210,20 @@ module REXML
173
210
  end
174
211
 
175
212
  def read_until(term)
176
- pattern = Regexp.union(term)
177
- begin
178
- until str = @scanner.scan_until(pattern)
179
- @scanner << readline(term)
180
- end
181
- rescue EOFError
182
- @scanner.rest
183
- else
213
+ pattern = Private::PRE_DEFINED_TERM_PATTERNS[term] || /#{Regexp.escape(term)}/
214
+ term = encode(term)
215
+ until str = @scanner.scan_until(pattern)
216
+ break if @source.nil?
217
+ break if @source.eof?
218
+ @scanner << readline(term)
219
+ end
220
+ if str
184
221
  read if @scanner.eos? and !@source.eof?
185
222
  str
223
+ else
224
+ rest = @scanner.rest
225
+ @scanner.pos = @scanner.string.bytesize
226
+ rest
186
227
  end
187
228
  end
188
229
 
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rexml
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.8
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 2024-05-16 00:00:00.000000000 Z
11
+ date: 2024-06-11 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: strscan
@@ -15,14 +16,14 @@ dependencies:
15
16
  requirements:
16
17
  - - ">="
17
18
  - !ruby/object:Gem::Version
18
- version: 3.0.9
19
+ version: '0'
19
20
  type: :runtime
20
21
  prerelease: false
21
22
  version_requirements: !ruby/object:Gem::Requirement
22
23
  requirements:
23
24
  - - ">="
24
25
  - !ruby/object:Gem::Version
25
- version: 3.0.9
26
+ version: '0'
26
27
  description: An XML toolkit for Ruby
27
28
  email:
28
29
  - kou@cozmixng.org
@@ -116,6 +117,7 @@ homepage: https://github.com/ruby/rexml
116
117
  licenses:
117
118
  - BSD-2-Clause
118
119
  metadata: {}
120
+ post_install_message:
119
121
  rdoc_options:
120
122
  - "--main"
121
123
  - README.md
@@ -132,7 +134,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
134
  - !ruby/object:Gem::Version
133
135
  version: '0'
134
136
  requirements: []
135
- rubygems_version: 3.6.0.dev
137
+ rubygems_version: 3.4.20
138
+ signing_key:
136
139
  specification_version: 4
137
140
  summary: An XML toolkit for Ruby
138
141
  test_files: []