Skip to content

Commit

Permalink
Merge pull request #85 from commonlit/gh-regex-match
Browse files Browse the repository at this point in the history
Use Regexp#match? over String#=~ when testing for null bytes
  • Loading branch information
bf4 authored Feb 21, 2024
2 parents 0249300 + ba11a31 commit fa9924c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rack/utf8_sanitizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def call(env)
input.
force_encoding(Encoding::ASCII_8BIT).
encode!(Encoding::UTF_8)
if sanitize_null_bytes && input =~ NULL_BYTE_REGEX
if sanitize_null_bytes && NULL_BYTE_REGEX.match?(input)
raise NullByteInString
end
input
Expand Down

0 comments on commit fa9924c

Please sign in to comment.