-
Notifications
You must be signed in to change notification settings - Fork 85
Added XML declaration check & Source#skip_spaces method
#282
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
Conversation
How about adding |
3bab763 to
9ededdc
Compare
|
I modified it to use |
Source#skip_spaces? method
Source#skip_spaces? methodSource#skip_spaces method
lib/rexml/parsers/baseparser.rb
Outdated
| end | ||
| name = parse_name(base_error_message) | ||
| @source.match?(/\s*/um, true) # skip spaces | ||
| @source.match?(Private::CUT_SPACES, true) |
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 use @source.skip_spaces here too?
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 is cool!
Thanks!
## Why? In the case of `@source.match?(/\s+/um, true)`, if there are no spaces at the beginning, I want to stop reading immediately. However, it continues to read the buffer until it finds a match, but it never finds a match. As a result, it continues reading until the end of the file. In the case of large XML files, drop_parsed_content occur frequently until the buffer is cleared, which may affect performance.
## Why? - The version attribute is required in XML declaration. - Only version attribute, encoding attribute, and standalone attribute are allowed in XML declaration. - XML declaration is only allowed once. See: https://www.w3.org/TR/xml/#NT-XMLDecl
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.
+1
|
Thank you for your reviews. |
Why?
Added XML declaration check
See: https://www.w3.org/TR/xml/#NT-XMLDecl
Added
Source#skip_spacesmethodIn the case of
@source.match?(/\s+/um, true), if there are no spaces at the beginning, I want to stop reading immediately.However, it continues to read the buffer until it finds a match, but it never finds a match.
As a result, it continues reading until the end of the file.
In the case of large XML files, drop_parsed_content occur frequently until the buffer is cleared, which may affect performance.
Benchmark