Commit a5e1905d authored by Grzegorz Bizon's avatar Grzegorz Bizon

Render 404 when artifacts path is invalid

parent f948c007
......@@ -17,6 +17,7 @@ class Projects::ArtifactsController < Projects::ApplicationController
def browse
return render_404 unless build.artifacts?
@path = build.artifacts_metadata_string_path(params[:path] || './')
return render_404 if @path.universe.empty?
end
private
......
......@@ -22,7 +22,7 @@ module Gitlab
paths, metadata = [], []
each do |line|
next unless line =~ %r{^#{Regexp.escape(@path)}[^/\s]+/?\s}
next unless line =~ %r{^#{Regexp.escape(@path)}[^/\s]*/?\s}
path, meta = line.split(' ')
paths.push(path)
......
......@@ -38,7 +38,8 @@ describe Gitlab::Ci::Build::Artifacts::Metadata do
it 'matches correct paths' do
expect(subject.first).
to contain_exactly 'other_artifacts_0.1.2/doc_sample.txt',
to contain_exactly 'other_artifacts_0.1.2/',
'other_artifacts_0.1.2/doc_sample.txt',
'other_artifacts_0.1.2/another-subdirectory/'
end
end
......@@ -48,7 +49,8 @@ describe Gitlab::Ci::Build::Artifacts::Metadata do
it 'matches correct paths' do
expect(subject.first).
to contain_exactly 'other_artifacts_0.1.2/another-subdirectory/empty_directory/',
to contain_exactly 'other_artifacts_0.1.2/another-subdirectory/',
'other_artifacts_0.1.2/another-subdirectory/empty_directory/',
'other_artifacts_0.1.2/another-subdirectory/banana_sample.gif'
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