rexml 3.2.8 → 3.2.9
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 +4 -4
- data/NEWS.md +28 -2
- data/lib/rexml/node.rb +8 -4
- data/lib/rexml/parsers/baseparser.rb +21 -2
- data/lib/rexml/rexml.rb +1 -1
- data/lib/rexml/source.rb +30 -9
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed57404d6f519cb196d671fd629380f5b08a50cf649ae99a71432edceaf15014
|
4
|
+
data.tar.gz: 9097f235049d98aa743998da10724fd6ff5f6cd0cb4f230c59290af4a75e2134
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d7a0be04c12fcd88c64dd2962d4db49f57ed02c08e3f4628e8e546aea135c672839a19a950423afa72d0cf25af0554558f2261b6b5f2b23637f4ca47d43bd73
|
7
|
+
data.tar.gz: 28479b3b11de58e84f57dc88057f185eb2365998f7fbc9f0df78d5899bb9b241c6bb93d26a57ca1b54d8a058b743daa78a8df52c4ddbfbb5f7c94aeb97724808
|
data/NEWS.md
CHANGED
@@ -1,5 +1,32 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
+
## 3.2.9 - 2024-06-19 {#version-3-2-9}
|
4
|
+
|
5
|
+
### Improvements
|
6
|
+
|
7
|
+
* Added support for old strscan.
|
8
|
+
* GH-132
|
9
|
+
* Reported by Adam
|
10
|
+
|
11
|
+
* Improved attribute value parse performance.
|
12
|
+
* GH-135
|
13
|
+
* Patch by NAITOH Jun.
|
14
|
+
|
15
|
+
* Improved `REXML::Node#each_recursive` performance.
|
16
|
+
* GH-134
|
17
|
+
* GH-139
|
18
|
+
* Patch by Hiroya Fujinami.
|
19
|
+
|
20
|
+
* Improved text parse performance.
|
21
|
+
* Reported by mprogrammer.
|
22
|
+
|
23
|
+
### Thanks
|
24
|
+
|
25
|
+
* Adam
|
26
|
+
* NAITOH Jun
|
27
|
+
* Hiroya Fujinami
|
28
|
+
* mprogrammer
|
29
|
+
|
3
30
|
## 3.2.8 - 2024-05-16 {#version-3-2-8}
|
4
31
|
|
5
32
|
### Fixes
|
@@ -30,7 +57,7 @@
|
|
30
57
|
|
31
58
|
* Improved parse performance when an attribute has many `<`s.
|
32
59
|
|
33
|
-
* GH-
|
60
|
+
* GH-126
|
34
61
|
|
35
62
|
### Fixes
|
36
63
|
|
@@ -65,7 +92,6 @@
|
|
65
92
|
* jcavalieri
|
66
93
|
* DuKewu
|
67
94
|
|
68
|
-
|
69
95
|
## 3.2.6 - 2023-07-27 {#version-3-2-6}
|
70
96
|
|
71
97
|
### 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
|
-
|
56
|
-
|
57
|
-
|
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
|
-
|
431
|
-
text
|
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
data/lib/rexml/source.rb
CHANGED
@@ -34,6 +34,16 @@ module REXML
|
|
34
34
|
attr_reader :line
|
35
35
|
attr_reader :encoding
|
36
36
|
|
37
|
+
module Private
|
38
|
+
PRE_DEFINED_TERM_PATTERNS = {}
|
39
|
+
pre_defined_terms = ["'", '"', "<"]
|
40
|
+
pre_defined_terms.each do |term|
|
41
|
+
PRE_DEFINED_TERM_PATTERNS[term] = /#{Regexp.escape(term)}/
|
42
|
+
end
|
43
|
+
end
|
44
|
+
private_constant :Private
|
45
|
+
include Private
|
46
|
+
|
37
47
|
# Constructor
|
38
48
|
# @param arg must be a String, and should be a valid XML document
|
39
49
|
# @param encoding if non-null, sets the encoding of the source to this
|
@@ -69,7 +79,13 @@ module REXML
|
|
69
79
|
end
|
70
80
|
|
71
81
|
def read_until(term)
|
72
|
-
|
82
|
+
pattern = Private::PRE_DEFINED_TERM_PATTERNS[term] || /#{Regexp.escape(term)}/
|
83
|
+
data = @scanner.scan_until(pattern)
|
84
|
+
unless data
|
85
|
+
data = @scanner.rest
|
86
|
+
@scanner.pos = @scanner.string.bytesize
|
87
|
+
end
|
88
|
+
data
|
73
89
|
end
|
74
90
|
|
75
91
|
def ensure_buffer
|
@@ -163,6 +179,7 @@ module REXML
|
|
163
179
|
end
|
164
180
|
|
165
181
|
def read(term = nil)
|
182
|
+
term = encode(term) if term
|
166
183
|
begin
|
167
184
|
@scanner << readline(term)
|
168
185
|
true
|
@@ -173,16 +190,20 @@ module REXML
|
|
173
190
|
end
|
174
191
|
|
175
192
|
def read_until(term)
|
176
|
-
pattern = Regexp.
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
193
|
+
pattern = Private::PRE_DEFINED_TERM_PATTERNS[term] || /#{Regexp.escape(term)}/
|
194
|
+
term = encode(term)
|
195
|
+
until str = @scanner.scan_until(pattern)
|
196
|
+
break if @source.nil?
|
197
|
+
break if @source.eof?
|
198
|
+
@scanner << readline(term)
|
199
|
+
end
|
200
|
+
if str
|
184
201
|
read if @scanner.eos? and !@source.eof?
|
185
202
|
str
|
203
|
+
else
|
204
|
+
rest = @scanner.rest
|
205
|
+
@scanner.pos = @scanner.string.bytesize
|
206
|
+
rest
|
186
207
|
end
|
187
208
|
end
|
188
209
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rexml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2024-
|
10
|
+
date: 2024-06-09 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: strscan
|
@@ -15,14 +15,14 @@ dependencies:
|
|
15
15
|
requirements:
|
16
16
|
- - ">="
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version:
|
18
|
+
version: '0'
|
19
19
|
type: :runtime
|
20
20
|
prerelease: false
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
22
22
|
requirements:
|
23
23
|
- - ">="
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version:
|
25
|
+
version: '0'
|
26
26
|
description: An XML toolkit for Ruby
|
27
27
|
email:
|
28
28
|
- kou@cozmixng.org
|