Skip to content

Commit

Permalink
Merge pull request #12751 from Earlopain/fix-12703
Browse files Browse the repository at this point in the history
[Fix #12703] Fix an error for `Lint/MixedCaseRange` with invalid byte sequence in UTF-8
  • Loading branch information
koic committed Mar 7, 2024
2 parents af3bdeb + b3d3bb5 commit 3118f00
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
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

0 comments on commit 3118f00

Please sign in to comment.