Sha256: 51945f77b89b360540c74e7b57c19f7f4d7953ec6cc66506f3cfa4c2095fcd88

Contents?: true

Size: 596 Bytes

Versions: 4

Compression:

Stored size: 596 Bytes

Contents

module Raven
  class Processor::UTF8Conversion < Processor

    def process(value)
      if value.is_a? Array
        value.map { |v_| process v_ }
      elsif value.is_a? Hash
        value.merge(value) { |k, v_| process v_ }
      else
        clean_invalid_utf8_bytes(value)
      end
    end

    private

    def clean_invalid_utf8_bytes(obj)
      if obj.respond_to?(:to_utf8)
        obj.to_utf8
      elsif obj.respond_to?(:encoding)
        obj.encode('UTF-16', :invalid => :replace, :undef => :replace, :replace => '').encode('UTF-8')
      else
        obj
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
sentry-raven-0.12.0 lib/raven/processor/utf8conversion.rb
mustwin-sentry-raven-0.11.2 lib/raven/processor/utf8conversion.rb
sentry-raven-0.11.2 lib/raven/processor/utf8conversion.rb
sentry-raven-0.11.1 lib/raven/processor/utf8conversion.rb