diff --git a/lib/rackstash/filter/anonymize_ip_mask.rb b/lib/rackstash/filter/anonymize_ip_mask.rb index c5bb4a8..3b79fb8 100644 --- a/lib/rackstash/filter/anonymize_ip_mask.rb +++ b/lib/rackstash/filter/anonymize_ip_mask.rb @@ -8,6 +8,7 @@ require 'ipaddr' require 'rackstash/filter' +require 'rackstash/helpers/utf8' module Rackstash module Filter @@ -41,6 +42,8 @@ module Rackstash # filter :anonymize_ip_mask, {'source_ip' => 'source_ip'} # end class AnonymizeIPMask + include Rackstash::Helpers::UTF8 + # @param field_spec [Hash<#to_s => #to_s>] a `Hash` specifying which # fields should be anonymized and where the result should be stored. The # key described the name of the existing source field and the value the @@ -54,7 +57,7 @@ module Rackstash def initialize(field_spec, ipv4_mask: 8, ipv6_mask: 80) @fields = {} Hash(field_spec).each_pair do |key, value| - @fields[key.to_s] = value.to_s + @fields[utf8_encode(key)] = utf8_encode(value) end @ipv4_mask = Integer(ipv4_mask) diff --git a/lib/rackstash/filter/rename.rb b/lib/rackstash/filter/rename.rb index 2156065..8c7d66d 100644 --- a/lib/rackstash/filter/rename.rb +++ b/lib/rackstash/filter/rename.rb @@ -1,11 +1,12 @@ # frozen_string_literal: true # -# Copyright 2017 Holger Just +# Copyright 2017 - 2018 Holger Just # # This software may be modified and distributed under the terms # of the MIT license. See the LICENSE.txt file for details. require 'rackstash/filter' +require 'rackstash/helpers/utf8' module Rackstash module Filter @@ -17,13 +18,15 @@ module Rackstash # filter :rename, "HOST_OR_IP" => "client_ip" # end class Rename + include Rackstash::Helpers::UTF8 + # @param spec [Hash<#to_s => #to_s>] a `Hash` specifying how fields should # be renamed, with the existing field name as a hash key and the new # field name as the respective value. def initialize(spec) @rename = {} Hash(spec).each_pair do |key, value| - @rename[key.to_s] = value.to_s + @rename[utf8_encode(key)] = utf8_encode(value) end end diff --git a/lib/rackstash/filter/replace.rb b/lib/rackstash/filter/replace.rb index 8b5d31b..6447439 100644 --- a/lib/rackstash/filter/replace.rb +++ b/lib/rackstash/filter/replace.rb @@ -1,11 +1,12 @@ # frozen_string_literal: true # -# Copyright 2017 Holger Just +# Copyright 2017 - 2018 Holger Just # # This software may be modified and distributed under the terms # of the MIT license. See the LICENSE.txt file for details. require 'rackstash/filter' +require 'rackstash/helpers/utf8' module Rackstash module Filter @@ -30,6 +31,8 @@ module Rackstash # here, namely `String`, `Integer`, `Float`, `Hash`, `Array`, `nil`, `true`, # or `false`. class Replace + include Rackstash::Helpers::UTF8 + # @param spec [Hash<#to_s => #call,Object>] a `Hash` specifying new field # values for the named keys. Values can be given in the form of a fixed # value or a callable object (e.g. a `Proc`) which accepts the event as @@ -37,7 +40,7 @@ module Rackstash def initialize(spec) @replace = {} Hash(spec).each_pair do |key, value| - @replace[key.to_s] = value + @replace[utf8_encode(key)] = value end end