Skip to content

Commit

Permalink
Constant '' is frozen.
Browse files Browse the repository at this point in the history
  • Loading branch information
makyen committed Apr 1, 2023
1 parent b67073f commit 09eac98
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/models/spam_wave.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def post_matches?(post, site_ids = nil)
post_text = '' if post_text.nil?
# UTF-8 -> UTF-16 -> UTF-8 idea and code from [answer to: "ruby 1.9: invalid byte sequence in UTF-8"](https://stackoverflow.com/a/8873922)
# by [RubenLaguna](https://stackoverflow.com/users/90580/rubenlaguna), which is under a CC BY-SA 3.0 license.
post_text.encode!('UTF-16', 'UTF-8', invalid: :replace, replace: '')
post_text.encode!('UTF-8', 'UTF-16')
post_text = post_text.encode!('UTF-16', 'UTF-8', invalid: :replace, replace: '')
post_text = post_text.encode!('UTF-8', 'UTF-16')
Rails.logger.debug "[spam-wave] id: #{id}: #{name}:: post #{f}: encoding: #{post_text.encoding}"
return false unless regex.match?(post_text)
Rails.logger.debug "[spam-wave] id: #{id}: #{name}:: post_matches?: #{f}: MATCHES: post id: #{post.id}: #{post.title}"
Expand Down

0 comments on commit 09eac98

Please sign in to comment.