From 028d76497ccef3a8d11a3528cdf6b99e8d10f070 Mon Sep 17 00:00:00 2001 From: Pere Urbon-Bayes Date: Wed, 12 Aug 2015 15:31:52 +0200 Subject: [PATCH] add the missing magic header # encoding: utf-8 so all internal strings are UTF-8 in Ruby < 2.0 Fixes #3723 --- Rakefile | 1 + lib/bootstrap/bundler.rb | 1 + lib/bootstrap/environment.rb | 3 ++- lib/bootstrap/rspec.rb | 1 + lib/bootstrap/rubygems.rb | 1 + lib/logstash-core.rb | 3 ++- lib/logstash/config/mixin.rb | 1 - lib/logstash/environment.rb | 1 + lib/logstash/java_integration.rb | 3 ++- lib/logstash/namespace.rb | 1 - lib/logstash/patches.rb | 1 + lib/logstash/patches/bugfix_jruby_2558.rb | 1 + lib/logstash/patches/bundler.rb | 1 + lib/logstash/patches/cabin.rb | 1 + lib/logstash/patches/rubygems.rb | 1 + lib/logstash/patches/stronger_openssl_defaults.rb | 1 + lib/logstash/program.rb | 1 - lib/logstash/runner.rb | 1 - lib/logstash/string_interpolation.rb | 1 - lib/logstash/util/accessors.rb | 1 - lib/logstash/util/decorators.rb | 1 - lib/logstash/util/filetools.rb | 1 + lib/logstash/util/java_version.rb | 3 ++- lib/logstash/util/plugin_version.rb | 1 + lib/logstash/util/prctl.rb | 1 - lib/logstash/util/reporter.rb | 1 + lib/logstash/util/retryable.rb | 3 ++- lib/logstash/util/unicode_trimmer.rb | 1 + lib/pluginmanager/command.rb | 1 + lib/pluginmanager/gemfile.rb | 1 + lib/pluginmanager/install.rb | 1 + lib/pluginmanager/list.rb | 1 + lib/pluginmanager/main.rb | 1 + lib/pluginmanager/uninstall.rb | 1 + lib/pluginmanager/update.rb | 1 + lib/pluginmanager/util.rb | 1 + rakelib/bootstrap.rake | 1 - spec/core/conditionals_spec.rb | 1 + spec/core/config_mixin_spec.rb | 1 + spec/core/environment_spec.rb | 1 + spec/core/pipeline_spec.rb | 1 + spec/core/plugin_spec.rb | 1 + spec/core/runner_spec.rb | 1 + spec/core/timestamp_spec.rb | 1 + spec/coverage_helper.rb | 1 + spec/license_spec.rb | 1 + spec/logstash/agent_spec.rb | 1 + spec/spec_helper.rb | 1 + spec/util/java_version_spec.rb | 3 ++- spec/util/plugin_version_spec.rb | 1 + spec/util_spec.rb | 1 + 51 files changed, 48 insertions(+), 15 deletions(-) diff --git a/Rakefile b/Rakefile index d77311081b3..cf702f08752 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,4 @@ +# encoding: utf-8 $: << File.join(File.dirname(__FILE__), "lib") diff --git a/lib/bootstrap/bundler.rb b/lib/bootstrap/bundler.rb index be8a9622a85..23944d347fe 100644 --- a/lib/bootstrap/bundler.rb +++ b/lib/bootstrap/bundler.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 module LogStash module Bundler extend self diff --git a/lib/bootstrap/environment.rb b/lib/bootstrap/environment.rb index 7348eeced32..9f3e59f5b08 100644 --- a/lib/bootstrap/environment.rb +++ b/lib/bootstrap/environment.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 # bootstrap.rb contains the minimal code to be able to launch Bundler to eventually be able # to retrieve the core code in the logstash-core gem which can live under different paths # depending on the launch context (local dev, packaged, etc) @@ -46,4 +47,4 @@ def logstash_gem_home LogStash::Bundler.setup!({:without => [:build, :development]}) require ARGV.shift LogStash::Runner.new.main(ARGV) -end \ No newline at end of file +end diff --git a/lib/bootstrap/rspec.rb b/lib/bootstrap/rspec.rb index 2f477003dfb..f32057c7f9c 100755 --- a/lib/bootstrap/rspec.rb +++ b/lib/bootstrap/rspec.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require_relative "environment" LogStash::Bundler.setup!({:without => [:build]}) require "logstash/environment" diff --git a/lib/bootstrap/rubygems.rb b/lib/bootstrap/rubygems.rb index fb90e473f9e..06e1775c380 100644 --- a/lib/bootstrap/rubygems.rb +++ b/lib/bootstrap/rubygems.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 module LogStash module Rubygems extend self diff --git a/lib/logstash-core.rb b/lib/logstash-core.rb index bde05c37429..74f073326eb 100644 --- a/lib/logstash-core.rb +++ b/lib/logstash-core.rb @@ -1,2 +1,3 @@ +# encoding: utf-8 module LogStash -end \ No newline at end of file +end diff --git a/lib/logstash/config/mixin.rb b/lib/logstash/config/mixin.rb index ed89e570be6..12df2e232e8 100644 --- a/lib/logstash/config/mixin.rb +++ b/lib/logstash/config/mixin.rb @@ -1,5 +1,4 @@ # encoding: utf-8 - require "logstash/namespace" require "logstash/config/registry" require "logstash/logging" diff --git a/lib/logstash/environment.rb b/lib/logstash/environment.rb index ad6b31da44f..8f710eed088 100644 --- a/lib/logstash/environment.rb +++ b/lib/logstash/environment.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require "logstash/errors" require "logstash/version" diff --git a/lib/logstash/java_integration.rb b/lib/logstash/java_integration.rb index 8d37d95755e..27ef229e07d 100644 --- a/lib/logstash/java_integration.rb +++ b/lib/logstash/java_integration.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require "java" # this is mainly for usage with JrJackson json parsing in :raw mode which genenerates @@ -96,4 +97,4 @@ def |(other) def inspect "<#{self.class.name}:#{self.hashCode} #{self.to_a(&:inspect)}>" end -end \ No newline at end of file +end diff --git a/lib/logstash/namespace.rb b/lib/logstash/namespace.rb index 72a1fc2e6cf..44701c38450 100644 --- a/lib/logstash/namespace.rb +++ b/lib/logstash/namespace.rb @@ -1,5 +1,4 @@ # encoding: utf-8 - module LogStash module Inputs; end module Outputs; end diff --git a/lib/logstash/patches.rb b/lib/logstash/patches.rb index f33c91c5ce5..8a3b3aa85e6 100644 --- a/lib/logstash/patches.rb +++ b/lib/logstash/patches.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require "logstash/patches/bugfix_jruby_2558" require "logstash/patches/cabin" require "logstash/patches/profile_require_calls" diff --git a/lib/logstash/patches/bugfix_jruby_2558.rb b/lib/logstash/patches/bugfix_jruby_2558.rb index 34f5d521a36..3aec48c0d3e 100644 --- a/lib/logstash/patches/bugfix_jruby_2558.rb +++ b/lib/logstash/patches/bugfix_jruby_2558.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require "logstash/environment" if LogStash::Environment.windows? && LogStash::Environment.jruby? diff --git a/lib/logstash/patches/bundler.rb b/lib/logstash/patches/bundler.rb index bcfe02074a8..25d93a09148 100644 --- a/lib/logstash/patches/bundler.rb +++ b/lib/logstash/patches/bundler.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 # Bundler monkey patches module ::Bundler # Patch bundler to write a .lock file specific to the version of ruby. diff --git a/lib/logstash/patches/cabin.rb b/lib/logstash/patches/cabin.rb index 63b5f6e1581..bb44fa2a421 100644 --- a/lib/logstash/patches/cabin.rb +++ b/lib/logstash/patches/cabin.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 if ENV["PROFILE_BAD_LOG_CALLS"] || ($DEBUGLIST || []).include?("log") # Set PROFILE_BAD_LOG_CALLS=1 in your environment if you want # to track down logger calls that cause performance problems diff --git a/lib/logstash/patches/rubygems.rb b/lib/logstash/patches/rubygems.rb index ebea50329bf..0576424eb15 100644 --- a/lib/logstash/patches/rubygems.rb +++ b/lib/logstash/patches/rubygems.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 # monkey patch RubyGems to silence ffi warnings: # # WARN: Unresolved specs during Gem::Specification.reset: diff --git a/lib/logstash/patches/stronger_openssl_defaults.rb b/lib/logstash/patches/stronger_openssl_defaults.rb index a1d8419d9f8..f1239b1d516 100644 --- a/lib/logstash/patches/stronger_openssl_defaults.rb +++ b/lib/logstash/patches/stronger_openssl_defaults.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require "openssl" # :nodoc: diff --git a/lib/logstash/program.rb b/lib/logstash/program.rb index 06940fd2291..bf9b3c67b2b 100644 --- a/lib/logstash/program.rb +++ b/lib/logstash/program.rb @@ -1,5 +1,4 @@ # encoding: utf-8 - require "logstash/namespace" module LogStash::Program diff --git a/lib/logstash/runner.rb b/lib/logstash/runner.rb index 9f425a6f8bb..4831d533025 100644 --- a/lib/logstash/runner.rb +++ b/lib/logstash/runner.rb @@ -1,5 +1,4 @@ # encoding: utf-8 - Thread.abort_on_exception = true Encoding.default_external = Encoding::UTF_8 $DEBUGLIST = (ENV["DEBUG"] || "").split(",") diff --git a/lib/logstash/string_interpolation.rb b/lib/logstash/string_interpolation.rb index 2340f0a8b4c..04bb55edc49 100644 --- a/lib/logstash/string_interpolation.rb +++ b/lib/logstash/string_interpolation.rb @@ -1,5 +1,4 @@ # encoding: utf-8 - require "thread_safe" require "forwardable" diff --git a/lib/logstash/util/accessors.rb b/lib/logstash/util/accessors.rb index d169be240c9..01c16910855 100644 --- a/lib/logstash/util/accessors.rb +++ b/lib/logstash/util/accessors.rb @@ -1,5 +1,4 @@ # encoding: utf-8 - require "logstash/namespace" require "logstash/util" require "thread_safe" diff --git a/lib/logstash/util/decorators.rb b/lib/logstash/util/decorators.rb index 3be970d2bf3..0ea2c021aca 100644 --- a/lib/logstash/util/decorators.rb +++ b/lib/logstash/util/decorators.rb @@ -1,5 +1,4 @@ # encoding: utf-8 - require "logstash/namespace" require "logstash/util" diff --git a/lib/logstash/util/filetools.rb b/lib/logstash/util/filetools.rb index 1031d59aba3..ed2f2b9acf9 100644 --- a/lib/logstash/util/filetools.rb +++ b/lib/logstash/util/filetools.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require "net/http" require "uri" require "digest/sha1" diff --git a/lib/logstash/util/java_version.rb b/lib/logstash/util/java_version.rb index df4897651e9..f5348d6201e 100644 --- a/lib/logstash/util/java_version.rb +++ b/lib/logstash/util/java_version.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require 'cabin' module LogStash::Util::JavaVersion @@ -61,4 +62,4 @@ def self.bad_java_version?(version_string) false end end -end \ No newline at end of file +end diff --git a/lib/logstash/util/plugin_version.rb b/lib/logstash/util/plugin_version.rb index 1266646e684..509ab3be224 100644 --- a/lib/logstash/util/plugin_version.rb +++ b/lib/logstash/util/plugin_version.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require 'logstash/errors' require 'rubygems/version' require 'forwardable' diff --git a/lib/logstash/util/prctl.rb b/lib/logstash/util/prctl.rb index 02f44f0d2cb..8d8bb5c7826 100644 --- a/lib/logstash/util/prctl.rb +++ b/lib/logstash/util/prctl.rb @@ -1,5 +1,4 @@ # encoding: utf-8 - module LibC require "ffi" extend FFI::Library diff --git a/lib/logstash/util/reporter.rb b/lib/logstash/util/reporter.rb index 7ea5f260ebf..4d983a25e3e 100644 --- a/lib/logstash/util/reporter.rb +++ b/lib/logstash/util/reporter.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 class InflightEventsReporter def self.logger=(logger) @logger = logger diff --git a/lib/logstash/util/retryable.rb b/lib/logstash/util/retryable.rb index b5ca2ddb204..04df5ce8c4a 100644 --- a/lib/logstash/util/retryable.rb +++ b/lib/logstash/util/retryable.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 module LogStash module Retryable # execute retryable code block @@ -36,4 +37,4 @@ def retryable(options = {}, &block) end end end -end \ No newline at end of file +end diff --git a/lib/logstash/util/unicode_trimmer.rb b/lib/logstash/util/unicode_trimmer.rb index 1e91fe91ff6..b8bb1c0d365 100644 --- a/lib/logstash/util/unicode_trimmer.rb +++ b/lib/logstash/util/unicode_trimmer.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 module LogStash::Util::UnicodeTrimmer # The largest possible unicode chars are 4 bytes # http://stackoverflow.com/questions/9533258/what-is-the-maximum-number-of-bytes-for-a-utf-8-encoded-character diff --git a/lib/pluginmanager/command.rb b/lib/pluginmanager/command.rb index 692a126ab4b..4adc46544c1 100644 --- a/lib/pluginmanager/command.rb +++ b/lib/pluginmanager/command.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 class LogStash::PluginManager::Command < Clamp::Command def gemfile @gemfile ||= LogStash::Gemfile.new(File.new(LogStash::Environment::GEMFILE_PATH, 'r+')).load diff --git a/lib/pluginmanager/gemfile.rb b/lib/pluginmanager/gemfile.rb index e57d73e8732..b1648187764 100644 --- a/lib/pluginmanager/gemfile.rb +++ b/lib/pluginmanager/gemfile.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 module LogStash class GemfileError < StandardError; end diff --git a/lib/pluginmanager/install.rb b/lib/pluginmanager/install.rb index 2596d356dbe..bbc486ab236 100644 --- a/lib/pluginmanager/install.rb +++ b/lib/pluginmanager/install.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require "pluginmanager/command" require "jar-dependencies" require "jar_install_post_install_hook" diff --git a/lib/pluginmanager/list.rb b/lib/pluginmanager/list.rb index 7fd32cbe3db..b4b96cafbc3 100644 --- a/lib/pluginmanager/list.rb +++ b/lib/pluginmanager/list.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require 'rubygems/spec_fetcher' require "pluginmanager/command" diff --git a/lib/pluginmanager/main.rb b/lib/pluginmanager/main.rb index 923d5225d00..c2f15775932 100644 --- a/lib/pluginmanager/main.rb +++ b/lib/pluginmanager/main.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 $LOAD_PATH.unshift(File.expand_path(File.join(__FILE__, "..", ".."))) require "bootstrap/environment" diff --git a/lib/pluginmanager/uninstall.rb b/lib/pluginmanager/uninstall.rb index acc77b3fbc8..e7598a4ebc9 100644 --- a/lib/pluginmanager/uninstall.rb +++ b/lib/pluginmanager/uninstall.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require "pluginmanager/command" class LogStash::PluginManager::Uninstall < LogStash::PluginManager::Command diff --git a/lib/pluginmanager/update.rb b/lib/pluginmanager/update.rb index 59ea4e936ef..0d067991677 100644 --- a/lib/pluginmanager/update.rb +++ b/lib/pluginmanager/update.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require "pluginmanager/command" require "jar-dependencies" require "jar_install_post_install_hook" diff --git a/lib/pluginmanager/util.rb b/lib/pluginmanager/util.rb index e16f16b6cb5..f5d08dae6bd 100644 --- a/lib/pluginmanager/util.rb +++ b/lib/pluginmanager/util.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require "rubygems/package" module LogStash::PluginManager diff --git a/rakelib/bootstrap.rake b/rakelib/bootstrap.rake index 6e8db74ac5b..7d9c2e6880b 100644 --- a/rakelib/bootstrap.rake +++ b/rakelib/bootstrap.rake @@ -1,2 +1 @@ - task "bootstrap" => [ "vendor:all", "compile:all" ] diff --git a/spec/core/conditionals_spec.rb b/spec/core/conditionals_spec.rb index 7dc9f7af46b..dab6fc901e3 100644 --- a/spec/core/conditionals_spec.rb +++ b/spec/core/conditionals_spec.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require 'spec_helper' module ConditionalFanciness diff --git a/spec/core/config_mixin_spec.rb b/spec/core/config_mixin_spec.rb index 31d8aaad6d6..128f6287b5f 100644 --- a/spec/core/config_mixin_spec.rb +++ b/spec/core/config_mixin_spec.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require "spec_helper" require "logstash/config/mixin" diff --git a/spec/core/environment_spec.rb b/spec/core/environment_spec.rb index e9b2cbca621..581ef6ae8be 100644 --- a/spec/core/environment_spec.rb +++ b/spec/core/environment_spec.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require "spec_helper" require "logstash/environment" diff --git a/spec/core/pipeline_spec.rb b/spec/core/pipeline_spec.rb index c1f4c99d9a8..89ad07ef4bd 100644 --- a/spec/core/pipeline_spec.rb +++ b/spec/core/pipeline_spec.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require "spec_helper" class DummyInput < LogStash::Inputs::Base diff --git a/spec/core/plugin_spec.rb b/spec/core/plugin_spec.rb index 432af8f5e58..8248c37b75e 100644 --- a/spec/core/plugin_spec.rb +++ b/spec/core/plugin_spec.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require "spec_helper" require "logstash/plugin" diff --git a/spec/core/runner_spec.rb b/spec/core/runner_spec.rb index 7f22bdd7f49..b61cab7bf30 100644 --- a/spec/core/runner_spec.rb +++ b/spec/core/runner_spec.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require "spec_helper" require "logstash/runner" require "stud/task" diff --git a/spec/core/timestamp_spec.rb b/spec/core/timestamp_spec.rb index c8b70cd8efd..17f403ca009 100644 --- a/spec/core/timestamp_spec.rb +++ b/spec/core/timestamp_spec.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require "spec_helper" require "logstash/timestamp" diff --git a/spec/coverage_helper.rb b/spec/coverage_helper.rb index 82710a67d70..6ecb2f570eb 100644 --- a/spec/coverage_helper.rb +++ b/spec/coverage_helper.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 # Useful module to help loading all logstash content when # running coverage analysis module CoverageHelper diff --git a/spec/license_spec.rb b/spec/license_spec.rb index e7a692f495e..6e8da1a7693 100644 --- a/spec/license_spec.rb +++ b/spec/license_spec.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require 'spec_helper' require 'rakelib/default_plugins' diff --git a/spec/logstash/agent_spec.rb b/spec/logstash/agent_spec.rb index 3d44c00d7b0..54f994d88f4 100644 --- a/spec/logstash/agent_spec.rb +++ b/spec/logstash/agent_spec.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require 'spec_helper' describe LogStash::Agent do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d52ff8be413..5428fd8fd90 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require_relative 'coverage_helper' # In order to archive an expected coverage analysis we need to eager load # all logstash code base, otherwise it will not get a good analysis. diff --git a/spec/util/java_version_spec.rb b/spec/util/java_version_spec.rb index 46e394f8a8d..d619b2d9e5f 100644 --- a/spec/util/java_version_spec.rb +++ b/spec/util/java_version_spec.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require 'spec_helper' require 'logstash/util/java_version' @@ -71,4 +72,4 @@ include_examples("version parsing", "an update+build", "1.4.0_03-beta", 1, 4, 0, 3, "beta") end -end \ No newline at end of file +end diff --git a/spec/util/plugin_version_spec.rb b/spec/util/plugin_version_spec.rb index 21c35f87dff..684c8bc5ed9 100644 --- a/spec/util/plugin_version_spec.rb +++ b/spec/util/plugin_version_spec.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require "spec_helper" require "logstash/util/plugin_version" diff --git a/spec/util_spec.rb b/spec/util_spec.rb index a1995be1c5c..82e75092675 100644 --- a/spec/util_spec.rb +++ b/spec/util_spec.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require 'spec_helper' require "logstash/util"