Skip to content

in_http: replace WEBrick::HTTPUtils.parse_query with URI #4900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/fluent/plugin/in_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -531,12 +531,12 @@ def on_message_complete
@env['REMOTE_ADDR'] = @remote_addr if @remote_addr

uri = URI.parse(@parser.request_url)
params = WEBrick::HTTPUtils.parse_query(uri.query)
params = parse_query(uri.query)

if @format_name != 'default'
params[EVENT_RECORD_PARAMETER] = @body
elsif /^application\/x-www-form-urlencoded/.match?(@content_type)
params.update WEBrick::HTTPUtils.parse_query(@body)
params.update parse_query(@body)
elsif @content_type =~ /^multipart\/form-data; boundary=(.+)/
boundary = WEBrick::HTTPUtils.dequote($1)
params.update WEBrick::HTTPUtils.parse_form_data(@body, boundary)
Expand All @@ -553,7 +553,7 @@ def on_message_complete

if (@add_query_params)

query_params = WEBrick::HTTPUtils.parse_query(uri.query)
query_params = parse_query(uri.query)

query_params.each_pair {|k,v|
params["QUERY_#{k.tr('-','_').upcase}"] = v
Expand Down Expand Up @@ -643,6 +643,10 @@ def include_cors_allow_origin

!r.nil?
end

def parse_query(query)
query.nil? ? {} : Hash[URI.decode_www_form(query, Encoding::ASCII_8BIT)]
end
end
end
end