mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/rexml/parsers/sax2parser.rb (REXML::Parsers::SAX2Parser#parse):
Fix wrong "%" position in parameter entity declaration event argument. * test/rexml/parser/test_sax2.rb: Add tests for the above case. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e0fff0d2b8
commit
7e0022bc8e
3 changed files with 65 additions and 2 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
Sun Aug 11 18:40:25 2013 Kouhei Sutou <kou@cozmixng.org>
|
||||||
|
|
||||||
|
* lib/rexml/parsers/sax2parser.rb (REXML::Parsers::SAX2Parser#parse):
|
||||||
|
Fix wrong "%" position in parameter entity declaration event argument.
|
||||||
|
* test/rexml/parser/test_sax2.rb: Add tests for the above case.
|
||||||
|
|
||||||
Sun Aug 11 18:08:40 2013 Kouhei Sutou <kou@cozmixng.org>
|
Sun Aug 11 18:08:40 2013 Kouhei Sutou <kou@cozmixng.org>
|
||||||
|
|
||||||
* lib/rexml/parsers/sax2parser.rb (REXML::Parsers::SAX2Parser#parse):
|
* lib/rexml/parsers/sax2parser.rb (REXML::Parsers::SAX2Parser#parse):
|
||||||
|
|
|
@ -177,12 +177,28 @@ module REXML
|
||||||
handle( :characters, copy )
|
handle( :characters, copy )
|
||||||
when :entitydecl
|
when :entitydecl
|
||||||
@entities[ event[1] ] = event[2] if event.size == 3
|
@entities[ event[1] ] = event[2] if event.size == 3
|
||||||
|
parameter_reference_p = false
|
||||||
case event[2]
|
case event[2]
|
||||||
when "SYSTEM"
|
when "SYSTEM"
|
||||||
event[4, 0] = "NDATA" if event.size == 5
|
if event.size == 5
|
||||||
when "PUBLIC"
|
if event.last == "%"
|
||||||
event[5, 0] = "NDATA" if event.size == 6
|
parameter_reference_p = true
|
||||||
|
else
|
||||||
|
event[4, 0] = "NDATA"
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
when "PUBLIC"
|
||||||
|
if event.size == 6
|
||||||
|
if event.last == "%"
|
||||||
|
parameter_reference_p = true
|
||||||
|
else
|
||||||
|
event[5, 0] = "NDATA"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
parameter_reference_p = (event.size == 4)
|
||||||
|
end
|
||||||
|
event[1, 0] = event.pop if parameter_reference_p
|
||||||
handle( event[0], event[1..-1] )
|
handle( event[0], event[1..-1] )
|
||||||
when :processing_instruction, :comment, :attlistdecl,
|
when :processing_instruction, :comment, :attlistdecl,
|
||||||
:elementdecl, :cdata, :notationdecl, :xmldecl
|
:elementdecl, :cdata, :notationdecl, :xmldecl
|
||||||
|
|
|
@ -103,6 +103,47 @@ class TestSAX2Parser < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class TestParameterEntity < self
|
||||||
|
class TestValue < self
|
||||||
|
def test_double_quote
|
||||||
|
assert_equal([["%", "name", "value"]], parse(<<-INTERNAL_SUBSET))
|
||||||
|
<!ENTITY % name "value">
|
||||||
|
INTERNAL_SUBSET
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_single_quote
|
||||||
|
assert_equal([["%", "name", "value"]], parse(<<-INTERNAL_SUBSET))
|
||||||
|
<!ENTITY % name 'value'>
|
||||||
|
INTERNAL_SUBSET
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class TestExternlID < self
|
||||||
|
def test_system
|
||||||
|
declaration = [
|
||||||
|
"%",
|
||||||
|
"name",
|
||||||
|
"SYSTEM", "system-literal",
|
||||||
|
]
|
||||||
|
assert_equal([declaration],
|
||||||
|
parse(<<-INTERNAL_SUBSET))
|
||||||
|
<!ENTITY % name SYSTEM "system-literal">
|
||||||
|
INTERNAL_SUBSET
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_public
|
||||||
|
declaration = [
|
||||||
|
"%",
|
||||||
|
"name",
|
||||||
|
"PUBLIC", "public-literal", "system-literal",
|
||||||
|
]
|
||||||
|
assert_equal([declaration], parse(<<-INTERNAL_SUBSET))
|
||||||
|
<!ENTITY % name PUBLIC "public-literal" "system-literal">
|
||||||
|
INTERNAL_SUBSET
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue