diff options
author | Bob Van Landuyt <bob@gitlab.com> | 2017-05-30 15:05:52 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-05-30 15:05:52 +0000 |
commit | 33aed43e9db41a9e482beb5e47800de8d6efbe31 (patch) | |
tree | fe2011a68623ba6e2c8ffa2ae2dbc128fe4286dd /spec/validators | |
parent | 374486fb2e1d51a059490a375d7fcd7aca4f65b8 (diff) | |
download | gitlab-ce-33aed43e9db41a9e482beb5e47800de8d6efbe31.tar.gz |
Avoid crash when trying to parse string with invalid UTF-8 sequence
Diffstat (limited to 'spec/validators')
-rw-r--r-- | spec/validators/dynamic_path_validator_spec.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/validators/dynamic_path_validator_spec.rb b/spec/validators/dynamic_path_validator_spec.rb index 5f998e78f07..8dbf3eecd23 100644 --- a/spec/validators/dynamic_path_validator_spec.rb +++ b/spec/validators/dynamic_path_validator_spec.rb @@ -3,6 +3,28 @@ require 'spec_helper' describe DynamicPathValidator do let(:validator) { described_class.new(attributes: [:path]) } + def expect_handles_invalid_utf8 + expect { yield('\255invalid') }.to be_falsey + end + + describe '.valid_user_path' do + it 'handles invalid utf8' do + expect(described_class.valid_user_path?("a\0weird\255path")).to be_falsey + end + end + + describe '.valid_group_path' do + it 'handles invalid utf8' do + expect(described_class.valid_group_path?("a\0weird\255path")).to be_falsey + end + end + + describe '.valid_project_path' do + it 'handles invalid utf8' do + expect(described_class.valid_project_path?("a\0weird\255path")).to be_falsey + end + end + describe '#path_valid_for_record?' do context 'for project' do it 'calls valid_project_path?' do |