Skip to content

Commit

Permalink
fix: Resolve Ruby deprecation warning (in Ruby 2.7)/error (in 3.0)
Browse files Browse the repository at this point in the history
Fixes #580
  • Loading branch information
twometresteve committed Jan 27, 2020
1 parent c0cd88b commit d8497b3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/bugsnag/cleaner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

module Bugsnag
class Cleaner
ENCODING_OPTIONS = {:invalid => :replace, :undef => :replace}.freeze
FILTERED = '[FILTERED]'.freeze
RECURSION = '[RECURSION]'.freeze
OBJECT = '[OBJECT]'.freeze
Expand Down Expand Up @@ -60,9 +59,9 @@ def traverse_object(obj, seen, scope)
def clean_string(str)
if defined?(str.encoding) && defined?(Encoding::UTF_8)
if str.encoding == Encoding::UTF_8
str.valid_encoding? ? str : str.encode('utf-16', ENCODING_OPTIONS).encode('utf-8')
str.valid_encoding? ? str : str.encode('utf-16', invalid: :replace, undef: :replace).encode('utf-8')
else
str.encode('utf-8', ENCODING_OPTIONS)
str.encode('utf-8', invalid: :replace, undef: :replace)
end
elsif defined?(Iconv)
Iconv.conv('UTF-8//IGNORE', 'UTF-8', str) || str
Expand Down

0 comments on commit d8497b3

Please sign in to comment.