File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -406,12 +406,11 @@ def pull_event
406
406
if md [ 0 ] [ 0 ] == ?-
407
407
md = @source . match ( /--(.*?)-->/um , true )
408
408
409
- case md [ 1 ]
410
- when /--/ , /-\z /
409
+ if md . nil? || /--|-\z / . match? ( md [ 1 ] )
411
410
raise REXML ::ParseException . new ( "Malformed comment" , @source )
412
411
end
413
412
414
- return [ :comment , md [ 1 ] ] if md
413
+ return [ :comment , md [ 1 ] ]
415
414
else
416
415
md = @source . match ( /\[ CDATA\[ (.*?)\] \] >/um , true )
417
416
return [ :cdata , md [ 1 ] ] if md
Original file line number Diff line number Diff line change @@ -68,6 +68,19 @@ def test_doctype_malformed_comment_end
68
68
DETAIL
69
69
end
70
70
71
+ def test_after_doctype_malformed_comment_short
72
+ exception = assert_raise ( REXML ::ParseException ) do
73
+ parse ( "<a><!-->" )
74
+ end
75
+ assert_equal ( <<~DETAIL . chomp , exception . to_s )
76
+ Malformed comment
77
+ Line: 1
78
+ Position: 8
79
+ Last 80 unconsumed characters:
80
+ -->
81
+ DETAIL
82
+ end
83
+
71
84
def test_after_doctype_malformed_comment_inner
72
85
exception = assert_raise ( REXML ::ParseException ) do
73
86
parse ( "<a><!-- -- -->" )
You can’t perform that action at this time.
0 commit comments