Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Resolve Ruby deprecation warning (in Ruby 2.7)/error (in 3.0) #582

Merged
merged 2 commits into from
Jan 29, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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