Commit 53458129 authored by Mikołaj Wawrzyniak's avatar Mikołaj Wawrzyniak

Merge branch 'psk-fix-overwriting-query-params' into 'master'

Fix overwriting path params by query params

See merge request gitlab-org/gitlab!74021
parents f7007a7f e9a20105
...@@ -31,7 +31,7 @@ module Routing ...@@ -31,7 +31,7 @@ module Routing
end end
end end
generate_url(masked_params.merge(masked_query_params)) generate_url(masked_params.merge(params: masked_query_params))
end end
private private
...@@ -45,7 +45,7 @@ module Routing ...@@ -45,7 +45,7 @@ module Routing
elsif @request.path_parameters[:controller] == 'groups/insights' elsif @request.path_parameters[:controller] == 'groups/insights'
default_root_url + "#{Gitlab::Routing.url_helpers.group_insights_path(masked_params)}" default_root_url + "#{Gitlab::Routing.url_helpers.group_insights_path(masked_params)}"
else else
Gitlab::Routing.url_helpers.url_for(masked_params.merge(masked_query_params)) Gitlab::Routing.url_helpers.url_for(masked_params)
end end
end end
......
...@@ -178,6 +178,26 @@ RSpec.describe ::Routing::PseudonymizationHelper do ...@@ -178,6 +178,26 @@ RSpec.describe ::Routing::PseudonymizationHelper do
it_behaves_like 'masked url' it_behaves_like 'masked url'
end end
context 'when query string has keys with the same names as path params' do
let(:masked_url) { "http://localhost/dashboard/issues?action=foobar&scope=all&state=opened" }
let(:request) do
double(:Request,
path_parameters: {
controller: 'dashboard',
action: 'issues'
},
protocol: 'http',
host: 'localhost',
query_string: 'action=foobar&scope=all&state=opened')
end
before do
allow(helper).to receive(:request).and_return(request)
end
it_behaves_like 'masked url'
end
end end
describe 'when url has no params to mask' do describe 'when url has no params to mask' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment