regex_match_group: handle non UTF-8 encoded strings

This commit is contained in:
Rylan Polster 2020-07-06 01:26:34 -04:00
parent e0b5c2093a
commit 1a703a1234

View File

@ -35,7 +35,7 @@ module RuboCop
# Checks for regex match of pattern in the node and
# sets the appropriate instance variables to report the match
def regex_match_group(node, pattern)
string_repr = string_content(node)
string_repr = string_content(node).encode("UTF-8", invalid: :replace)
match_object = string_repr.match(pattern)
return unless match_object