-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a bug that a large XML can't be parsed (#154)
GitHub: fix GH-150 If a parsed XML is later than `2 ** 31 - 1`, we can't parse it. Because `StringScanner`s position is stored as `int`. We can avoid the restriction by dropping large parsed content. Co-authored-by: Sutou Kouhei <[email protected]>
- Loading branch information
Showing
3 changed files
with
36 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,27 @@ | ||
# frozen_string_literal: false | ||
|
||
require 'rexml/parsers/baseparser' | ||
|
||
module REXMLTests | ||
class BaseParserTester < Test::Unit::TestCase | ||
def test_large_xml | ||
large_text = "a" * 100_000 | ||
xml = <<-XML | ||
<?xml version="1.0"?> | ||
<root> | ||
<child>#{large_text}</child> | ||
<child>#{large_text}</child> | ||
</root> | ||
XML | ||
|
||
parser = REXML::Parsers::BaseParser.new(xml) | ||
while parser.has_next? | ||
parser.pull | ||
end | ||
|
||
assert do | ||
parser.position < xml.bytesize | ||
end | ||
end | ||
end | ||
end |