Skip to content
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 #12703] Fix an error for Lint/MixedCaseRange with invalid byte sequence in UTF-8 #12751

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/fix_error_for_lint_mixed_case_range.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#12703](https://github.com/rubocop/rubocop/issues/12703): Fix an error for `Lint/MixedCaseRange` with invalid byte sequence in UTF-8. ([@earlopain][])
2 changes: 1 addition & 1 deletion lib/rubocop/cop/utils/regexp_ranges.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def compose_range(expressions, current)
end

def escaped_octal?(expr)
expr.text =~ /^\\[0-7]$/
expr.text.valid_encoding? && expr.text =~ /^\\[0-7]$/
end

def octal_digit?(char)
Expand Down
6 changes: 6 additions & 0 deletions spec/rubocop/cop/lint/mixed_case_range_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,10 @@
foo = /[a-[bc]]/
RUBY
end

it 'does not register an offense with invalid byte sequence in UTF-8' do
expect_no_offenses(<<~'RUBY')
foo = /[\–]/
RUBY
end
end