Skip to content
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

Address warning: URI::RFC3986_PARSER warnings against ruby 3.4.0dev #812

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
11 changes: 7 additions & 4 deletions lib/sprockets/uri_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ module Sprockets
module URIUtils
extend self

URI_PARSER = defined?(URI::RFC2396_PARSER) ? URI::RFC2396_PARSER : URI::Generic::DEFAULT_PARSER
private_constant :URI_PARSER

# Internal: Parse URI into component parts.
#
# uri - String uri
Expand All @@ -45,7 +48,7 @@ def join_uri(scheme, userinfo, host, port, registry, path, opaque, query, fragme
def split_file_uri(uri)
scheme, _, host, _, _, path, _, query, _ = URI.split(uri)

path = URI::Generic::DEFAULT_PARSER.unescape(path)
path = URI_PARSER.unescape(path)
path.force_encoding(Encoding::UTF_8)

# Hack for parsing Windows "/C:/Users/IEUser" paths
Expand All @@ -63,7 +66,7 @@ def join_file_uri(scheme, host, path, query)
str = +"#{scheme}://"
str << host if host
path = "/#{path}" unless path.start_with?("/".freeze)
str << URI::Generic::DEFAULT_PARSER.escape(path)
str << URI_PARSER.escape(path)
str << "?#{query}" if query
str
end
Expand Down Expand Up @@ -162,7 +165,7 @@ def encode_uri_query_params(params)
when Integer
query << "#{key}=#{value}"
when String, Symbol
query << "#{key}=#{URI::Generic::DEFAULT_PARSER.escape(value.to_s)}"
query << "#{key}=#{URI_PARSER.escape(value.to_s)}"
when TrueClass
query << "#{key}"
when FalseClass, NilClass
Expand All @@ -182,7 +185,7 @@ def encode_uri_query_params(params)
def parse_uri_query_params(query)
query.to_s.split('&'.freeze).reduce({}) do |h, p|
k, v = p.split('='.freeze, 2)
v = URI::Generic::DEFAULT_PARSER.unescape(v) if v
v = URI_PARSER.unescape(v) if v
h[k.to_sym] = v || true
h
end
Expand Down
Loading