-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix a bug that a large XML can't be parsed #154
Conversation
70bce7e
to
57fa969
Compare
test/test_baseparser.rb
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you move this to test/parser/test_base_parser.rb
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
I see.
test/test_baseparser.rb
Outdated
|
||
module REXMLTests | ||
class BaseParserTester < Test::Unit::TestCase | ||
include REXML |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needless.
include REXML |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
I see.
test/test_baseparser.rb
Outdated
parser = REXML::Parsers::BaseParser.new(xml) | ||
while parser.has_next? | ||
parser.pull | ||
assert_compare REXML::Source::SCANNER_RESET_SIZE + N_STRING.size, ">", parser.position |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!!! Can we access SCANNER_REST_SIZE
via REXML::Source
even when we use private_constant
!?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
20| require 'debug'
21| def test_parse_large_xml
22| xml = build_xml(N_ELEMENTS)
23| parser = REXML::Parsers::BaseParser.new(xml)
=> 24| debugger
25| while parser.has_next?
26| parser.pull
27| assert_compare REXML::Source::SCANNER_RESET_SIZE + N_STRING.size, ">", parser.position
28| end
=>#0 REXMLTests::BaseParserTester#test_parse_large_xml at ~/ghq/github.com/naitoh/rexml/test/parser/test_base.rb:24
#1 Test::Unit::TestCase#run_test at ~/.rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/test-unit-3.6.1/lib/test/unit/testcase.rb:871
# and 28 frames (use `bt' command for all frames)
(ruby) puts REXML::Source::SCANNER_RESET_SIZE
100000
nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh... It seems that we should remove include Private
(in a separated PR)...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes...
57fa969
to
71a4f82
Compare
…exceeds a certain size, have it removed. See: ruby#150 --------- Co-authored-by: Sutou Kouhei <kou@clear-code.com>
71a4f82
to
758b6b4
Compare
Thanks. |
Included constants are not private. So private constants in private module aren't private. See also: #154 (comment)
GitHub: fix GH-150
If a parsed XML is later than
2 ** 31 - 1
, we can't parse it. BecauseStringScanner
s position is stored asint
. We can avoid the restriction by dropping large parsed content.