summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-04 06:53:57 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-04 06:53:57 +0000
commite440bfaed184b2fbbc37a838362a2f79280637cb (patch)
tree7d536cdc7acd7f6faac2b0e84fd75a1bc8acba2c /lib
parent478d3dffa24a200dd595a7f50a58bb8ff3e1e0c0 (diff)
rexml: Fix a XPath bug of /child::node()
[Bug #14600] * lib/rexml/xpath_parser.rb: Fix a bug that "/child::node()" returns XML declaration and text nodes out of root element. * test/rexml/test_jaxen.rb: Enable more tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63088 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/rexml/xpath_parser.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/rexml/xpath_parser.rb b/lib/rexml/xpath_parser.rb
index f663215b07..a94ad91ea1 100644
--- a/lib/rexml/xpath_parser.rb
+++ b/lib/rexml/xpath_parser.rb
@@ -212,7 +212,19 @@ module REXML
nodeset.each do |node|
nt = node.node_type
# trace(:child, nt, node)
- new_nodeset += node.children if nt == :element or nt == :document
+ case nt
+ when :element
+ new_nodeset.concat(node.children)
+ when :document
+ node.children.each do |child|
+ case child
+ when XMLDecl, Text
+ # ignore
+ else
+ new_nodeset << child
+ end
+ end
+ end
end
nodeset = new_nodeset
node_types = ELEMENTS