Ticket #45 (closed defect: fixed)
Notation declarations are incorrectly parsed
| Reported by: | self@… | Owned by: | ser |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.1.4 |
| Component: | DOM | Version: | 3.1.2 |
| Severity: | normal | Keywords: | NotationDecl, Notation |
| Cc: | Ruby version: | Other | |
| Operating system: | Linux |
Description (last modified by ser) (diff)
If a Doctype declaration contains two notation declarations, like this:
<!NOTATION n1 PUBLIC "-//HM//NOTATION TEST1//EN" 'urn:x-henrikmartensson.org:test5'>
<!NOTATION n2 PUBLIC '-//HM//NOTATION TEST2//EN' "urn:x-henrikmartensson.org:test6">
REXML will be confused after parsing the first declararation, and believe the second declaration is part of the first one.
The problem occurs only when one of the identifiers in a notation is enclosed in double quotes, and the other is enclosed in single quotes.
See the following unit test for an example:
#! /usr/bin/ruby
require 'test/unit'
require 'rexml/document'
# Mix in convenience methods in REXML classes
module REXML
class NotationDecl
def name
@name
end
end
class DocType
def notations
children().select {|node| node.kind_of?(REXML::NotationDecl)}
end
def notation(name)
notations.find { |notation_decl|
notation_decl.name == name
}
end
end
end
class TestNotationDecl < Test::Unit::TestCase
def setup
doc_string = <<-'XMLEND'
<!DOCTYPE r SYSTEM "urn:x-henrikmartensson:test" [
<!NOTATION n1 PUBLIC "-//HM//NOTATION TEST1//EN" 'urn:x-henrikmartensson.org:test5'>
<!NOTATION n2 PUBLIC '-//HM//NOTATION TEST2//EN' "urn:x-henrikmartensson.org:test6">
]>
<r/>
XMLEND
@doctype = REXML::Document.new(doc_string).doctype
end
def test_notation
assert(@doctype.notation('n1'), "Testing notation n1")
assert(@doctype.notation('n2'), "Testing notation n2")
end
end
Attachments
Change History
Note: See
TracTickets for help on using
tickets.
