Skip to content

Commit

Permalink
Fix URI::RFC2396_PARSER issue with older Rubies
Browse files Browse the repository at this point in the history
Switching to URI::RFC2396_PARSER in 028fd33 resulted in
problems with older versions of Ruby where URI::RFC2396_PARSER is not
defined. Although URI::RFC2396_PARSER was added and backported to the
vendored uri library in older versions of Ruby, we check for
URI::RFC2396_PARSER's presence such that the warnings are avoided when
using a newer non-vendored version of the gem.
  • Loading branch information
tekin authored and whitequark committed Jan 10, 2025
1 parent 664e8ab commit f2a6335
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/rack/utf8_sanitizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,11 @@ def unescape_unreserved(input)
# Performs the reverse function of `unescape_unreserved`. Unlike
# the previous function, we can reuse the logic in URI#encode
def escape_unreserved(input)
URI::RFC2396_PARSER.escape(input, UNSAFE)
if Object.const_defined?("URI::RFC2396_PARSER")
URI::RFC2396_PARSER.escape(input, UNSAFE)
else
URI::DEFAULT_PARSER.escape(input, UNSAFE)
end
end

def sanitize_string(input)
Expand Down

0 comments on commit f2a6335

Please sign in to comment.