diff --git a/lib/rexml/parsers/baseparser.rb b/lib/rexml/parsers/baseparser.rb index 47380f0d..5688c773 100644 --- a/lib/rexml/parsers/baseparser.rb +++ b/lib/rexml/parsers/baseparser.rb @@ -430,7 +430,7 @@ def pull_event #STDERR.puts "SOURCE BUFFER = #{source.buffer}, #{source.buffer.size}" raise REXML::ParseException.new("Malformed node", @source) unless md if md[0][0] == ?- - md = @source.match(/--(.*?)-->/um, true) + md = @source.match(/--(.*?)-->/um, true, term: Private::COMMENT_TERM) if md.nil? || /--|-\z/.match?(md[1]) raise REXML::ParseException.new("Malformed comment", @source) diff --git a/test/parse/test_comment.rb b/test/parse/test_comment.rb index 543d9ad8..50c765f5 100644 --- a/test/parse/test_comment.rb +++ b/test/parse/test_comment.rb @@ -128,5 +128,12 @@ def test_gt_linear_performance REXML::Document.new('') end end + + def test_gt_linear_performance_in_element + seq = [10000, 50000, 100000, 150000, 200000] + assert_linear_performance(seq, rehearsal: 10) do |n| + REXML::Document.new('') + end + end end end