-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If the size of the content parsed by StringScanner to parse huge XML …
…exceeds a certain size, have it removed. See: #150
- Loading branch information
Showing
3 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: false | ||
|
||
require 'rexml/parsers/baseparser' | ||
|
||
module REXMLTests | ||
class BaseParserTester < Test::Unit::TestCase | ||
include REXML | ||
|
||
N_ELEMENTS = 100 | ||
N_STRING = 'a' * 50000 | ||
def build_xml(n_elements) | ||
xml = '<?xml version="1.0"?><root>' | ||
|
||
n_elements.times do |i| | ||
xml << '<child >' | ||
xml << N_STRING | ||
xml << '</child>' | ||
end | ||
xml << '</root>' | ||
end | ||
|
||
def test_parse_large_xml | ||
xml = build_xml(N_ELEMENTS) | ||
parser = REXML::Parsers::BaseParser.new(xml) | ||
while parser.has_next? | ||
parser.pull | ||
assert_compare REXML::Source::SCANNER_RESET_SIZE + N_STRING.size, ">", parser.position | ||
end | ||
end | ||
end | ||
end |