This file is indexed.

/usr/lib/ruby/vendor_ruby/rack/typhoeus/middleware/params_decoder.rb is in ruby-typhoeus 0.6.3-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
require 'rack/typhoeus/middleware/params_decoder/helper'

module Rack
  module Typhoeus
    module Middleware

      # This Rack middleware takes care of the proper deserialization of
      # the nested params encoded by Typhoeus.
      #
      # @example Require the railtie when using Rails.
      #   require 'typhoeus/railtie'
      #
      # @example Include the middleware for Rack based applications.
      #   use Rack::Typhoeus::Middleware::ParamsDecoder
      #
      # @example Use the helper directly. Not recommended as b/c the interface might change.
      #   require 'rack/typhoeus/middleware/params_decoder/helper'
      #   include Rack::Typhoeus::Middleware::ParamsDecoder::Helper
      #   decode!(params)
      #
      # @author Dwayne Macgowan
      # @since 0.5.4
      class ParamsDecoder
        include ParamsDecoder::Helper

        def initialize(app)
          @app = app
        end

        def call(env)
          req = Rack::Request.new(env)
          decode(req.params).each_pair { |k, v| update_params req, k, v }
          @app.call(env)
        end

        private

        # Persist params change in environment. Extracted from:
        # https://github.com/rack/rack/blob/master/lib/rack/request.rb#L233
        def update_params(req, k, v)
          found = false
          if req.GET.has_key?(k)
            found = true
            req.GET[k] = v
          end
          if req.POST.has_key?(k)
            found = true
            req.POST[k] = v
          end
          unless found
            req.GET[k] = v
          end
        end
      end
    end
  end
end