diff options
author | Kouhei Sutou <[email protected]> | 2019-01-01 06:32:18 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2019-08-04 11:54:27 +0900 |
commit | 0f18bc7fca0668aa2ffeb15106525526e4f018ba (patch) | |
tree | 19b366029204501871ca1ea9d186aeda2095555d /lib/rexml/xpath_parser.rb | |
parent | 9b36f0a787dfb1a2a3875b827b455b5a9a2f2680 (diff) |
[ruby/rexml] Fix attribute's default namespace behavior
NOTE: It's a backward incompatible change. If we have any serious
problems with this change, we may revert this change.
The XML namespace specification says the default namespace doesn't
apply to attribute names but it does in REXML without this change:
https://www.w3.org/TR/xml-names/#uniqAttrs
> the default namespace does not apply to attribute names
REXML reports a parse error for the following XML that is described as
a valid XML in the XML nsmaspace specification without this change:
<!-- http://www.w3.org is bound to n1 and is the default -->
<x xmlns:n1="http://www.w3.org"
xmlns="http://www.w3.org" >
<good a="1" b="2" />
<good a="1" n1:a="2" />
</x>
If attribute doesn't have prefix, the attribute should return "" for
both #prefix and #namespace.
https://github.com/ruby/rexml/commit/9e4fd552bc
Diffstat (limited to 'lib/rexml/xpath_parser.rb')
-rw-r--r-- | lib/rexml/xpath_parser.rb | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/lib/rexml/xpath_parser.rb b/lib/rexml/xpath_parser.rb index 47fa4ef84e..321bc481af 100644 --- a/lib/rexml/xpath_parser.rb +++ b/lib/rexml/xpath_parser.rb @@ -493,17 +493,11 @@ module REXML if prefix.nil? raw_node.name == name elsif prefix.empty? - # FIXME: This DOUBLES the time XPath searches take - raw_node.name == name and - raw_node.namespace == raw_node.element.namespace + raw_node.name == name and raw_node.namespace == "" else # FIXME: This DOUBLES the time XPath searches take ns = get_namespace(raw_node.element, prefix) - if ns.empty? - raw_node.name == name and raw_node.prefix.empty? - else - raw_node.name == name and raw_node.namespace == ns - end + raw_node.name == name and raw_node.namespace == ns end else false |