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

update URLMap Regexp usage for Ruby v3.3 #3165

Merged
merged 4 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/puma/rack/urlmap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def remap(map)
end

location = location.chomp('/')
match = Regexp.new("^#{Regexp.quote(location).gsub('/', '/+')}(.*)", nil, 'n')
match = Regexp.new("^#{Regexp.quote(location).gsub('/', '/+')}(.*)", Regexp::NOENCODING)

[host, location, match, app]
}.sort_by do |(host, location, _, _)|
Expand Down
24 changes: 24 additions & 0 deletions test/test_url_map.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require_relative "helper"
require_relative "helpers/integration"

class TestURLMap < TestIntegration

def teardown
return if skipped?
super
end

# make sure the mapping defined in url_map_test/config.ru works
def test_basic_url_mapping
skip_if :jruby
env = { "BUNDLE_GEMFILE" => "#{__dir__}/url_map_test/Gemfile" }
Dir.chdir("#{__dir__}/url_map_test") do
cli_server set_pumactl_args, env: env
end
connection = connect("/ok")
# Puma 6.2.2 and below will time out here with Ruby v3.3
# see https://github.com/puma/puma/pull/3165
body = read_body(connection, 1)
assert_equal("OK", body)
end
end
1 change: 1 addition & 0 deletions test/url_map_test/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gem 'puma', path: '../..'
9 changes: 9 additions & 0 deletions test/url_map_test/config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
map "/ok" do
run ->(env) {
if Object.const_defined?(:Rack) && ::Rack.const_defined?(:URLMap)
[200, {}, ["::Rack::URLMap is loaded"]]
else
[200, {}, ["OK"]]
end
}
end