diff --git a/test/parse/test_entity_declaration.rb b/test/parse/test_entity_declaration.rb index a214b890..17677bbc 100644 --- a/test/parse/test_entity_declaration.rb +++ b/test/parse/test_entity_declaration.rb @@ -25,152 +25,153 @@ def parse(internal_subset) public class TestGeneralEntityDeclration < self - def test_garbaged_after_entity_definition + def test_invalid_entity_definition exception = assert_raise(REXML::ParseException) do - REXML::Document.new(' ]>') + REXML::Document.new(' ]>') end assert_equal(<<-DETAIL.chomp, exception.to_s) Malformed entity declaration Line: 1 -Position: 39 +Position: 68 Last 80 unconsumed characters: - \"foo\" xxx > ]> + \"valid-name\" invalid-entity-definition > ]> DETAIL end class TestSystemExternalEntities < self - def test_garbaged_between_system_and_literal + def test_invalid_external_entity_before_system_literal exception = assert_raise(REXML::ParseException) do - REXML::Document.new(' ]>') + REXML::Document.new(' ]>') end assert_equal(<<-DETAIL.chomp, exception.to_s) Malformed entity declaration Line: 1 -Position: 50 +Position: 94 Last 80 unconsumed characters: - foo SYSTEM xxx \"bar\" > ]> + valid-name SYSTEM invalid-external-entity \"valid-system-literal\" > ]> DETAIL end - def test_garbaged_after_literal + def test_invalid_external_entity_after_system_literal exception = assert_raise(REXML::ParseException) do - REXML::Document.new(' ]>') + REXML::Document.new(' ]>') end assert_equal(<<-DETAIL.chomp, exception.to_s) Malformed entity declaration Line: 1 -Position: 50 +Position: 94 Last 80 unconsumed characters: - foo SYSTEM \"bar\" xxx > ]> + valid-name SYSTEM \"valid-system-literal\" invalid-external-entity > ]> DETAIL end - def test_garbaged_between_literal_and_ndata_declaration + def test_invalid_external_entity_before_ndata_declaration exception = assert_raise(REXML::ParseException) do - REXML::Document.new(' ]>') + REXML::Document.new(' ]>') end assert_equal(<<-DETAIL.chomp, exception.to_s) Malformed entity declaration Line: 1 -Position: 60 +Position: 104 Last 80 unconsumed characters: - foo SYSTEM \"bar\" xxx NDATA gif > ]> + valid-name SYSTEM \"valid-system-literal\" invalid-external-entity NDATA gif > ]> DETAIL end - def test_garbaged_after_ndata_declaration + def test_invalid_external_entity_after_ndata_declaration exception = assert_raise(REXML::ParseException) do - REXML::Document.new(' ]>') + REXML::Document.new(' ]>') end assert_equal(<<-DETAIL.chomp, exception.to_s) Malformed entity declaration Line: 1 -Position: 60 +Position: 104 Last 80 unconsumed characters: - foo SYSTEM \"bar\" NDATA gif xxx > ]> + valid-name SYSTEM \"valid-system-literal\" NDATA gif invalid-external-entity > ]> DETAIL end end class TestPublicExternalEntities < self - def test_garbaged_between_public_and_first_literal + def test_invalid_external_entity_before_pubid_literal exception = assert_raise(REXML::ParseException) do - REXML::Document.new(' ]>') + REXML::Document.new(' ]>') end assert_equal(<<-DETAIL.chomp, exception.to_s) Malformed entity declaration Line: 1 -Position: 56 +Position: 116 Last 80 unconsumed characters: - foo PUBLIC xxx \"bar\" \"baz\" > ]> + valid-name PUBLIC invalid-external-entity \"valid-pubid-literal\" \"valid-system-li DETAIL end - def test_garbaged_between_literals + def test_invalid_external_entity_after_pubid_literal exception = assert_raise(REXML::ParseException) do - REXML::Document.new(' ]>') + REXML::Document.new(' ]>') end assert_equal(<<-DETAIL.chomp, exception.to_s) Malformed entity declaration Line: 1 -Position: 56 +Position: 116 Last 80 unconsumed characters: - foo PUBLIC \"bar\" xxx \"baz\" > ]> + valid-name PUBLIC \"valid-pubid-literal\" invalid-external-entity \"valid-system-li DETAIL end - def test_garbaged_after_literals + def test_invalid_external_entity_after_system_literal exception = assert_raise(REXML::ParseException) do - REXML::Document.new(' ]>') + REXML::Document.new(' ]>') end assert_equal(<<-DETAIL.chomp, exception.to_s) Malformed entity declaration Line: 1 -Position: 56 +Position: 116 Last 80 unconsumed characters: - foo PUBLIC \"bar\" \"baz\" xxx > ]> + valid-name PUBLIC \"valid-pubid-literal\" \"valid-system-literal\" invalid-external- DETAIL end - def test_garbaged_between_literal_and_ndata_declaration + def test_invalid_external_entity_before_ndata_declaration exception = assert_raise(REXML::ParseException) do - REXML::Document.new(' ]>') + REXML::Document.new(' ]>') end assert_equal(<<-DETAIL.chomp, exception.to_s) Malformed entity declaration Line: 1 -Position: 66 +Position: 126 Last 80 unconsumed characters: - foo PUBLIC \"bar\" \"baz\" xxx NDATA gif > ]> + valid-name PUBLIC \"valid-pubid-literal\" \"valid-system-literal\" invalid-external- DETAIL end - def test_garbaged_after_ndata_declaration + def test_invalid_external_entity_after_ndata_declaration exception = assert_raise(REXML::ParseException) do - REXML::Document.new(' ]>') + REXML::Document.new(' ]>') end assert_equal(<<-DETAIL.chomp, exception.to_s) Malformed entity declaration Line: 1 -Position: 66 +Position: 126 Last 80 unconsumed characters: - foo PUBLIC \"bar\" \"baz\" NDATA gif xxx > ]> + valid-name PUBLIC \"valid-pubid-literal\" \"valid-system-literal\" NDATA gif invalid DETAIL end end end class TestPublicIDLiteral < self - def test_pubid_literal + def test_invalid_pubid_char exception = assert_raise(REXML::ParseException) do - REXML::Document.new(' ]>') + # U+3042 HIRAGANA LETTER A + REXML::Document.new(" ]>") end assert_equal(<<-DETAIL.chomp, exception.to_s.force_encoding('utf-8')) Malformed entity declaration Line: 1 -Position: 58 +Position: 76 Last 80 unconsumed characters: - foo PUBLIC \"あいう\" \"bar\" > ]> + valid-name PUBLIC \"あ\" \"valid-system-literal\" > ]> DETAIL end end