mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 22:57:16 -04:00
ensure all strings pulled out of ENV are UTF8 on windows
strings assigned to LogStash::Event fields must be UTF-8 and since most windows aren't UTF-8 by default we must intercept all get operations and convert the strings to UTF-8. Issue surfaces in logstash-filter-environment, for example. Fixes #2666
This commit is contained in:
parent
e5c78c7c66
commit
6230084c20
1 changed files with 16 additions and 0 deletions
|
@ -32,3 +32,19 @@ if LogStash::Environment.windows? && LogStash::Environment.jruby?
|
||||||
include JRubyBug2558SocketPeerAddrBugFix
|
include JRubyBug2558SocketPeerAddrBugFix
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if LogStash::Environment.windows?
|
||||||
|
# make sure all strings pulled out of ENV are UTF8
|
||||||
|
class <<ENV
|
||||||
|
alias_method :orig_getter, :[]
|
||||||
|
def [](key)
|
||||||
|
case value = orig_getter(key)
|
||||||
|
when String
|
||||||
|
# dup is necessary since force_encoding is destructive
|
||||||
|
value.dup.force_encoding(Encoding::UTF_8)
|
||||||
|
else
|
||||||
|
value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue