-
Notifications
You must be signed in to change notification settings - Fork 88
Closed
Description
I think we should improve the implementation to handle nested CDATA more efficiently.
require "rexml/document"
include REXML
(1..1000000000).step(10000000) do |depth|
puts "Trying depth #{depth}"
string = "<?xml version=\"1.0\"?>\n" +
"<root>Test</root>\n" +
"<!" + "[CDATA[" * depth + "]]>\n"
start = Time.now
begin
doc = Document.new(string)
rescue Exception => e
puts "Error at depth #{depth}: #{e}"
break
end
elapsed_time = Time.now - start
puts "Elapsed time: #{elapsed_time} seconds"
endResult:
Elapsed time: 24.994068928 seconds
Trying depth 200000001
Elapsed time: 27.070803532 seconds
Trying depth 210000001
Elapsed time: 27.870487966 seconds
Trying depth 220000001
Elapsed time: 28.787843908 seconds
Trying depth 230000001
[1] 4336 killed ruby test.rb
Metadata
Metadata
Assignees
Labels
No labels