Commit 3b030e56 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'rs-uploaded-file-path' into 'master'

Handle blank file path in UploadedFile.from_params

See merge request gitlab-org/gitlab!28030
parents ddb0fefb 06d6eb18
...@@ -48,7 +48,7 @@ class UploadedFile ...@@ -48,7 +48,7 @@ class UploadedFile
return if path.blank? && remote_id.blank? return if path.blank? && remote_id.blank?
file_path = nil file_path = nil
if path if path.present?
file_path = File.realpath(path) file_path = File.realpath(path)
paths = Array(upload_paths) << Dir.tmpdir paths = Array(upload_paths) << Dir.tmpdir
......
...@@ -59,6 +59,16 @@ describe UploadedFile do ...@@ -59,6 +59,16 @@ describe UploadedFile do
expect(subject.sha256).to eq('sha256') expect(subject.sha256).to eq('sha256')
expect(subject.remote_id).to eq('remote_id') expect(subject.remote_id).to eq('remote_id')
end end
it 'handles a blank path' do
params['file.path'] = ''
# Not a real file, so can't determine size itself
params['file.size'] = 1.byte
expect { described_class.from_params(params, :file, upload_path) }
.not_to raise_error
end
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