Skip to content

Commit

Permalink
Merge pull request #582 from bugsnag/ruby-deprecation-warning
Browse files Browse the repository at this point in the history
fix: Resolve Ruby deprecation warning (in Ruby 2.7)/error (in 3.0)
  • Loading branch information
twometresteve authored Jan 29, 2020
2 parents 9b9a639 + 72b6143 commit 9114648
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 9114648

Please sign in to comment.