Skip to content

Commit

Permalink
Make "xml:" namespace a constant
Browse files Browse the repository at this point in the history
  • Loading branch information
KitaitiMakoto committed Sep 27, 2024
1 parent f98d418 commit f531b70
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/rexml/parsers/baseparser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ class BaseParser
"apos" => [/'/, "'", "'", /'/]
}

XML_PREFIXED_NAMESPACE = "http://www.w3.org/XML/1998/namespace"

module Private
PEREFERENCE_PATTERN = /#{PEREFERENCE}/um
TAG_PATTERN = /((?>#{QNAME_STR}))\s*/um
Expand Down Expand Up @@ -185,7 +187,7 @@ def stream=( source )
@tags = []
@stack = []
@entities = []
@namespaces = {"xml" => "http://www.w3.org/XML/1998/namespace"}
@namespaces = {"xml" => XML_PREFIXED_NAMESPACE}
@namespaces_restore_stack = []
end

Expand Down Expand Up @@ -790,7 +792,7 @@ def parse_attributes(prefixes)
@source.match(/\s*/um, true)
if prefix == "xmlns"
if local_part == "xml"
if value != "http://www.w3.org/XML/1998/namespace"
if value != XML_PREFIXED_NAMESPACE
msg = "The 'xml' prefix must not be bound to any other namespace "+
"(http://www.w3.org/TR/REC-xml-names/#ns-decl)"
raise REXML::ParseException.new( msg, @source, self )
Expand Down

0 comments on commit f531b70

Please sign in to comment.