tlux/rack-encoding_guard

View on GitHub
lib/rack/encoding_guard/sanitize_strategy.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Rack
  module EncodingGuard
    class SanitizeStrategy < Strategy
      def process(env)
        Strategy::PROCESSIBLE_KEYS.each do |key|
          env[key] = env[key].to_s.encode(Encoding::UTF_8, Encoding::BINARY,
                                          invalid: :replace, undef: :replace,
                                          replace: '')
        end
        yield
      end
    end
  end
end