Skip to content

Commit

Permalink
cleanup regex
Browse files Browse the repository at this point in the history
  • Loading branch information
jpalermo committed May 7, 2015
1 parent 789d728 commit 5257a8a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/cloud_controller/safe_zipper.rb
Expand Up @@ -73,8 +73,9 @@ def size
end

def any_outside_relative_paths?
zip_info.split("\n")[3..-3].find do |line|
is_outside?(line.match(/([^\s]+)$/)[1])
zip_info.split("\n")[3..-3].any? do |line|
match = line.match(/^\s*\d+\s+[\d-]+\s+[\d:]+\s+(.*)$/)
match && is_outside?(match[1])
end
end

Expand Down
Binary file added spec/fixtures/bad_relative_paths_with_spaces.zip
Binary file not shown.
8 changes: 8 additions & 0 deletions spec/unit/lib/safe_zipper_spec.rb
Expand Up @@ -96,6 +96,14 @@
expect { unzip }.to raise_exception VCAP::Errors::ApiError, /relative path.+outside/i
end
end

context 'when the are outside the root directory and have spaces' do
let(:zip_path) { File.expand_path('../../fixtures/bad_relative_paths_with_spaces.zip', File.dirname(__FILE__)) }

it 'raises an exception' do
expect { unzip }.to raise_exception VCAP::Errors::ApiError, /relative path.+outside/i
end
end
end
end

Expand Down

0 comments on commit 5257a8a

Please sign in to comment.