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 2 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
36 changes: 36 additions & 0 deletions test/test_url_map.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require_relative "helper"
require_relative "helpers/integration"

class TestURLMap < TestIntegration
def setup
skip_unless :fork
super
end

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_unless_signal_exist? :USR2

@tcp_port = UniquePort.call
timeout = 1
env = {
"BUNDLE_GEMFILE" => File.join(File.expand_path("url_map_test/Gemfile", __dir__))
}
cmd = "bundle exec puma -q -w 1 --prune-bundler -b tcp://#{HOST}:#{@tcp_port}"
Dir.chdir(File.expand_path("url_map_test", __dir__)) do
@server = IO.popen(env, cmd.split, "r")
end
wait_for_server_to_boot
@pid = @server.pid
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
initial_reply = read_body(connection, timeout)
assert_match("OK", initial_reply)
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: '../..'
3 changes: 3 additions & 0 deletions test/url_map_test/config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
map "/ok" do
run ->(env) { [200, {}, ["OK"]] }
end