Commit 915a4193 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'sanitize-new-project-error-message' into 'master'

Sanitize repo paths in new project error message

Closes #17243

See merge request !4029
parents 950ab1e8 75523d1d
...@@ -3,6 +3,7 @@ Please view this file on the master branch, on stable branches it's out of date. ...@@ -3,6 +3,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.8.0 (unreleased) v 8.8.0 (unreleased)
- Project#open_branches has been cleaned up and no longer loads entire records into memory. - Project#open_branches has been cleaned up and no longer loads entire records into memory.
- Make build status canceled if any of the jobs was canceled and none failed - Make build status canceled if any of the jobs was canceled and none failed
- Sanitize repo paths in new project error message
- Remove future dates from contribution calendar graph. - Remove future dates from contribution calendar graph.
- Support e-mail notifications for comments on project snippets - Support e-mail notifications for comments on project snippets
- Use ActionDispatch Remote IP for Akismet checking - Use ActionDispatch Remote IP for Akismet checking
......
...@@ -341,4 +341,10 @@ module ProjectsHelper ...@@ -341,4 +341,10 @@ module ProjectsHelper
) )
end end
end end
def sanitize_repo_path(message)
return '' unless message.present?
message.strip.gsub(Gitlab.config.gitlab_shell.repos_path.chomp('/'), "[REPOS PATH]")
end
end end
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
.panel-body .panel-body
%pre %pre
:preserve :preserve
#{@project.import_error.try(:strip)} #{sanitize_repo_path(@project.import_error)}
= form_for @project, url: namespace_project_import_path(@project.namespace, @project), method: :post, html: { class: 'form-horizontal' } do |f| = form_for @project, url: namespace_project_import_path(@project.namespace, @project), method: :post, html: { class: 'form-horizontal' } do |f|
= render "shared/import_form", f: f = render "shared/import_form", f: f
......
...@@ -131,4 +131,13 @@ describe ProjectsHelper do ...@@ -131,4 +131,13 @@ describe ProjectsHelper do
end end
end end
end end
describe '#sanitized_import_error' do
it 'removes the repo path' do
repo = File.join(Gitlab.config.gitlab_shell.repos_path, '/namespace/test.git')
import_error = "Could not clone #{repo}\n"
expect(sanitize_repo_path(import_error)).to eq('Could not clone [REPOS PATH]/namespace/test.git')
end
end
end end
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