8000 Add tests for no literal case · ruby/rexml@8b42c31 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8b42c31

Browse files
committed
Add tests for no literal case
1 parent 7e95837 commit 8b42c31

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

test/parse/test_entity_declaration.rb

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,32 @@ def test_mixed_quote_in_public
141141
valid-name PUBLIC \"valid-pubid-literal\" \"invalid-system-literal'>]>
142142
DETAIL
143143
end
144+
145+
def test_no_literal_in_system
146+
exception = assert_raise(REXML::ParseException) do
147+
REXML::Document.new('<!DOCTYPE root [<!ENTITY valid-name SYSTEM>]>')
148+
end
149+
assert_equal(<<-DETAIL.chomp, exception.to_s)
150+
Malformed entity declaration
151+
Line: 1
152+
Position: 45
153+
Last 80 unconsumed characters:
154+
valid-name SYSTEM>]>
155+
DETAIL
156+
end
157+
158+
def test_no_literal_in_public
159+
exception = assert_raise(REXML::ParseException) do
160+
REXML::Document.new('<!DOCTYPE root [<!ENTITY valid-name PUBLIC "valid-pubid-literal">]>')
161+
end
162+
assert_equal(<<-DETAIL.chomp, exception.to_s)
163+
Malformed entity declaration
164+
Line: 1
165+
Position: 67
166+
Last 80 unconsumed characters:
167+
valid-name PUBLIC \"valid-pubid-literal\">]>
168+
DETAIL
169+
end
144170
end
145171

146172
# https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-PubidLiteral
@@ -185,6 +211,19 @@ def test_mixed_quote
185211
valid-name PUBLIC \"invalid-pubid-literal' \"valid-system-literal\">]>
186212
DETAIL
187213
end
214+
215+
def test_no_literal
216+
exception = assert_raise(REXML::ParseException) do
217+
REXML::Document.new('<!DOCTYPE root [<!ENTITY valid-name PUBLIC>]>')
218+
end
219+
assert_equal(<<-DETAIL.chomp, exception.to_s)
220+
Malformed entity declaration
221+
Line: 1
222+
Position: 45
223+
Last 80 unconsumed characters:
224+
valid-name PUBLIC>]>
225+
DETAIL
226+
end
188227
end
189228
end
190229

@@ -350,6 +389,32 @@ def test_mixed_quote_in_public
350389
% valid-name PUBLIC \"valid-pubid-literal\" 'invalid-system-literal\">]>
351390
DETAIL
352391
end
392+
393+
def test_no_literal_in_system
394+
exception = assert_raise(REXML::ParseException) do
395+
REXML::Document.new('<!DOCTYPE root [<!ENTITY % valid-name SYSTEM>]>')
396+
end
397+
assert_equal(<<-DETAIL.chomp, exception.to_s)
398+
Malformed entity declaration
399+
Line: 1
400+
Position: 47
401+
Last 80 unconsumed characters:
402+
% valid-name SYSTEM>]>
403+
DETAIL
404+
end
405+
406+
def test_no_literal_in_public
407+
exception = assert_raise(REXML::ParseException) do
408+
REXML::Document.new('<!DOCTYPE root [<!ENTITY % valid-name PUBLIC "valid-pubid-literal">]>')
409+
end
410+
assert_equal(<<-DETAIL.chomp, exception.to_s)
411+
Malformed entity declaration
412+
Line: 1
413+
Position: 69
414+
Last 80 unconsumed characters:
415+
% valid-name PUBLIC \"valid-pubid-literal\">]>
416+
DETAIL
417+
end
353418
end
354419

355420
# https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-PubidLiteral
@@ -394,6 +459,19 @@ def test_mixed_quote
394459
% valid-name PUBLIC 'invalid-pubid-literal\" \"valid-system-literal\">]>
395460
DETAIL
396461
end
462+
463+
def test_no_literal
464+
exception = assert_raise(REXML::ParseException) do
465+
REXML::Document.new('<!DOCTYPE root [<!ENTITY % valid-name PUBLIC>]>')
466+
end
467+
assert_equal(<<-DETAIL.chomp, exception.to_s)
468+
Malformed entity declaration
469+
Line: 1
470+
Position: 47
471+
Last 80 unconsumed characters:
472+
% valid-name PUBLIC>]>
473+
DETAIL
474+
end
397475
end
398476
end
399477

0 commit comments

Comments
 (0)
0