Skip to content
This repository has been archived by the owner on Nov 29, 2017. It is now read-only.

Commit

Permalink
Merge pull request #96 from make-me/reject-local-files
Browse files Browse the repository at this point in the history
Reject local files
  • Loading branch information
skalnik committed Sep 27, 2013
2 parents 5f235d1 + 35320d7 commit 1614a9a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions server/app.rb
Expand Up @@ -76,6 +76,12 @@ def progress
slicer_args = (args[:slicer_args] || {})
quality = (args[:quality] || 'medium')

# ensure no URLs point ot the local file system
stl_urls.each do |url|
uri = URI.parse(url)
halt 406, "Need a remote file" if uri.scheme == 'file'
end

normalizer_args = {}
normalizer_args[:count] = count if count
normalizer_args[:scale] = scale if scale
Expand Down
5 changes: 5 additions & 0 deletions spec/app_spec.rb
Expand Up @@ -45,6 +45,11 @@
and_return(normalizer)
post '/print', Yajl::Encoder.encode({:url => urls, :scale => scale, :count => count})
end

it 'rejects local files' do
post '/print', Yajl::Encoder.encode({:url => ['file:///etc/passwd']})
expect(last_response.status).to eq(406)
end
end
end
end

0 comments on commit 1614a9a

Please sign in to comment.