Verified Commit 1b0949d6 authored by Bob Van Landuyt's avatar Bob Van Landuyt 💬
Browse files

fix: replace `CGI.parse` with `URI.decode_www_form` for Ruby 4

Ruby 4.0 removed the full CGI library from default gems
([Feature #21258][1]), keeping only `cgi/escape`. This broke
`TracingUtils.parse_query_string` which relied on `CGI.parse`.

Replace `CGI.parse` with `URI.decode_www_form` from stdlib, and
narrow `require "cgi"` to `require "cgi/escape"` where only
escape/unescape methods are needed.

[1]: https://bugs.ruby-lang.org/issues/21258
parent 927d8e2e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
# frozen_string_literal: true

require "base64"
require "cgi"
require "cgi/escape"
require "active_support"
require "active_support/core_ext"

+2 −2
Original line number Diff line number Diff line
# frozen_string_literal: true

require "cgi"
require "uri"
require "active_support/core_ext/string/starts_ends_with"
require "opentracing"

@@ -80,7 +80,7 @@ module Labkit
      def self.parse_query_string(query)
        return {} unless query

        CGI.parse(query).symbolize_keys.transform_values(&:first)
        URI.decode_www_form(query).each_with_object({}) { |(k, v), h| h[k.to_sym] ||= v }
      end
    end
  end