-
Notifications
You must be signed in to change notification settings - Fork 88
Use more StringScanner based API for parse_id #299
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
## Why? If parse_id_invalid_details_system is called, always `accept_external_id == true` and `@source.match?(Private::EXTERNAL_ID_SYSTEM_PATTERN) == true`.
# Why? accept_external_id is always true.
# Why? If `accept_public_id == true` and `@source.match?(Private::PUBLIC_ID_PATTERN) == true`, the `parse_id_invalid_details_public` method is not reached.
| end | ||
|
|
||
| def parse_id(base_error_message, | ||
| accept_external_id:, |
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.
We can remove this keyword argument because it's always true, right?
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.
rexml/lib/rexml/parsers/baseparser.rb
Lines 309 to 310 in 39e7e28
| id = parse_id(base_error_message, | |
| accept_external_id: true, |
rexml/lib/rexml/parsers/baseparser.rb
Lines 411 to 412 in 39e7e28
| id = parse_id(base_error_message, | |
| accept_external_id: true, |
lib/rexml/parsers/baseparser.rb
Outdated
| end | ||
| "garbage after system literal" | ||
| if @source.match?(/(?:\s+[^'"]|\s*[\[>])/um) | ||
| details = "public ID literal is missing" |
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.
How about raising here for better backtrace?
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.
e9b3969 to
d42a439
Compare
Why?
Improve maintainability by optimizing the process so that the parsing process proceeds using StringScanner.