File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -449,9 +449,7 @@ def pull_event
449
449
end
450
450
return [ :end_element , last_tag ]
451
451
elsif @source . match? ( "!" , true )
452
- md = @source . match ( /([^>]*>)/um )
453
452
#STDERR.puts "SOURCE BUFFER = #{source.buffer}, #{source.buffer.size}"
454
- raise REXML ::ParseException . new ( "Malformed node" , @source ) unless md
455
453
if @source . match? ( "--" , true )
456
454
return [ :comment , process_comment ]
457
455
elsif @source . match? ( "[CDATA[" , true )
@@ -461,9 +459,9 @@ def pull_event
461
459
else
462
460
raise REXML ::ParseException . new ( "Malformed CDATA: Missing end ']]>'" , @source )
463
461
end
462
+ else
463
+ raise REXML ::ParseException . new ( "Malformed node: Started with '<!' but not a comment nor CDATA" , @source )
464
464
end
465
- raise REXML ::ParseException . new ( "Declarations can only occur " +
466
- "in the doctype declaration." , @source )
467
465
elsif @source . match? ( "?" , true )
468
466
return process_instruction
469
467
else
Original file line number Diff line number Diff line change @@ -84,6 +84,19 @@ def test_doctype_malformed_comment_end
84
84
DETAIL
85
85
end
86
86
87
+ def test_after_doctype_malformed_node
88
+ exception = assert_raise ( REXML ::ParseException ) do
89
+ parse ( "<a><!a" )
90
+ end
91
+ assert_equal ( <<~DETAIL . chomp , exception . to_s )
92
+ Malformed node: Started with '<!' but not a comment nor CDATA
93
+ Line: 1
94
+ Position: 6
95
+ Last 80 unconsumed characters:
96
+ a
97
+ DETAIL
98
+ end
99
+
87
100
def test_after_doctype_unclosed_comment
88
101
exception = assert_raise ( REXML ::ParseException ) do
89
102
parse ( "<a><!-->" )
You can’t perform that action at this time.
0 commit comments