diff options
author | Mark Lapierre <mlapierre@gitlab.com> | 2019-05-06 13:07:31 +1000 |
---|---|---|
committer | Mark Lapierre <mlapierre@gitlab.com> | 2019-05-06 13:07:31 +1000 |
commit | f9e06897adfa550f675fdaa0166ec25f2add28f5 (patch) | |
tree | 676e2cbcbe77111942e96030a5ca78739f7599f8 /qa | |
parent | 9aa81c0a95b0e54bbafca4755e95f27ee1eeb759 (diff) | |
download | gitlab-ce-f9e06897adfa550f675fdaa0166ec25f2add28f5.tar.gz |
Escape arg used in regex
Diffstat (limited to 'qa')
-rw-r--r-- | qa/qa/git/repository.rb | 2 | ||||
-rw-r--r-- | qa/spec/git/repository_spec.rb | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/qa/qa/git/repository.rb b/qa/qa/git/repository.rb index b3bad40a90f..84353e3d0c7 100644 --- a/qa/qa/git/repository.rb +++ b/qa/qa/git/repository.rb @@ -251,7 +251,7 @@ module QA end def netrc_already_contains_content? - read_netrc_content.grep(/^#{netrc_content}$/).any? + read_netrc_content.grep(/^#{Regexp.escape(netrc_content)}$/).any? end end end diff --git a/qa/spec/git/repository_spec.rb b/qa/spec/git/repository_spec.rb index 776dce31d4f..fd77681797f 100644 --- a/qa/spec/git/repository_spec.rb +++ b/qa/spec/git/repository_spec.rb @@ -116,6 +116,15 @@ describe QA::Git::Repository do expect(File.read(File.join(tmp_netrc_dir, '.netrc'))) .to eq("machine foo login user password foo\n") end + + it 'adds credentials with special characters' do + password = %q(!"#$%&'()*+,-./:;<=>?) + repository.username = 'user' + repository.password = password + + expect(File.read(File.join(tmp_netrc_dir, '.netrc'))) + .to eq("machine foo login user password #{password}\n") + end end end end |