Repository navigation
Conversation
A Shift_JIS string positioned on 0xFF made skip return nil. The same call raises ArgumentError in strscan 3.1.6, and a caller that advances only after a match can loop. A position inside a valid two-byte character still misses.
The scan fast-path returned nil whenever the position was not a character head. That is right for the interior of a valid multibyte character, and wrong for an invalid byte: the regexp engine used to raise ArgumentError there. Only a position inside a complete character returns nil now. Fixes ruby#223
This branch has not been deployed
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.
Fixes #223.
skipreturned nil when the position was not a character head. That is the right result in the middle of a valid multibyte character, andtest_scan_at_non_character_boundarycovers it. An invalid byte is not that case. In strscan 3.1.6 the regexp engine raised, and a caller that moves forward only after a match loops if the answer is nil.On current master, before this change:
After it, the Shift_JIS position raises
ArgumentError: invalid byte sequence in Shift_JIS, matching 3.1.6 and the UTF-8 case. The interior of a valid character still returns nil, including a Shift_JIS two-byte character and the existing UTF-16 example.bundle exec rake testloads the compiled extension: 178 tests, 1141 assertions.