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 df74a0b commit aaf442b
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 = {}
@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 aaf442b

Please sign in to comment.