- strings are now assumed to always be Unicode

This fixes a bug where this caused a crash:

LANG=C bin/logstash agent -e 'filter { mutate { replace => { "message"
=> "☹" } } } output { stdout { codec => json } }'

The problem was that LANG=C told ruby's eval() what the encoding of
strings was by default, and since logstash requires UTF-8/unicode
elswhere, it makes sense to require it for the config file as well.
This commit is contained in:
Jordan Sissel 2013-09-09 11:01:30 -07:00
parent 45ac715e36
commit 7ca972e8d1
2 changed files with 11 additions and 3 deletions

View file

@ -196,19 +196,26 @@ module LogStash; module Config; module AST
end
class RValue < Node; end
class Value < RValue; end
module Unicode
def self.wrap(text)
return "(" + text.inspect + ".force_encoding(\"UTF-8\")" + ")"
end
end
class Bareword < Value
def compile
return text_value.inspect
return Unicode.wrap(text_value)
end
end
class String < Value
def compile
return text_value[1...-1].inspect
return Unicode.wrap(text_value[1...-1])
end
end
class RegExp < Value
def compile
return text_value
return "Regexp.new(" + Unicode.wrap(text_value[1...-1]) + ")"
end
end
class Number < Value

View file

@ -66,6 +66,7 @@ class LogStash::Outputs::Base < LogStash::Plugin
if !@tags.empty?
return false if !event["tags"]
@include_method = :any?
if !@tags.send(@include_method) {|tag| event["tags"].include?(tag)}
@logger.debug? and @logger.debug("outputs/#{self.class.name}: Dropping event because tags don't match #{@tags.inspect}", event)
return false