Use more StringScanner based API for parse_id#299
Merged
kou merged 9 commits intoruby:masterfrom Sep 14, 2025
Merged
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.
kou
reviewed
Sep 14, 2025
| end | ||
|
|
||
| def parse_id(base_error_message, | ||
| accept_external_id:, |
Member
There was a problem hiding this comment.
We can remove this keyword argument because it's always true, right?
Contributor
Author
There was a problem hiding this comment.
Yes.
rexml/lib/rexml/parsers/baseparser.rb
Lines 309 to 310 in 39e7e28
rexml/lib/rexml/parsers/baseparser.rb
Lines 411 to 412 in 39e7e28
kou
reviewed
Sep 14, 2025
lib/rexml/parsers/baseparser.rb
Outdated
| end | ||
| "garbage after system literal" | ||
| if @source.match?(/(?:\s+[^'"]|\s*[\[>])/um) | ||
| details = "public ID literal is missing" |
Member
There was a problem hiding this comment.
How about raising here for better backtrace?
e9b3969 to
d42a439
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why?
Improve maintainability by optimizing the process so that the parsing process proceeds using StringScanner.