This repository was archived by the owner on Mar 27, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -225,7 +225,7 @@ def rewrite_partial_path_info(env, request)
225225 env [ 'PATH_INFO' ] = "/"
226226 env [ 'SCRIPT_NAME' ] += path_info_before
227227 else
228- env [ 'PATH_INFO' ] = "/#{ request . path . join ( '/' ) } "
228+ env [ 'PATH_INFO' ] = "/#{ URI . encode ( request . path . join ( '/' ) ) } "
229229 env [ 'SCRIPT_NAME' ] += path_info_before [ 0 , path_info_before . size - env [ 'PATH_INFO' ] . size ]
230230 end
231231 end
Original file line number Diff line number Diff line change @@ -72,4 +72,22 @@ def test_script_name_from_partial_match_of_single
7272 router . call ( Rack ::MockRequest . env_for ( "/sidekiq" ) )
7373 assert_equal ( '/sidekiq' , request_env [ 'SCRIPT_NAME' ] )
7474 end
75+
76+ def test_path_info_with_encoded_request_path
77+ request_env = nil
78+ router do
79+ add ( "/sidekiq*" ) . to { |env | request_env = env ; [ 200 , { } , [ ] ] }
80+ end
81+ router . call ( Rack ::MockRequest . env_for ( "/sidekiq/queues/some%20path" ) )
82+ assert_equal ( '/queues/some%20path' , request_env [ 'PATH_INFO' ] )
83+ end
84+
85+ def test_script_name_with_encoded_request_path
86+ request_env = nil
87+ router do
88+ add ( "/sidekiq*" ) . to { |env | request_env = env ; [ 200 , { } , [ ] ] }
89+ end
90+ router . call ( Rack ::MockRequest . env_for ( "/sidekiq/queues/some%20path" ) )
91+ assert_equal ( '/sidekiq' , request_env [ 'SCRIPT_NAME' ] )
92+ end
7593end
You can’t perform that action at this time.
0 commit comments