diff options
author | Brandon Everett <bme2010@gmail.com> | 2017-09-13 15:39:50 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-09-13 15:39:50 +0300 |
commit | 528f90b4e5d82f803f29c37fcfc1206e3b3bf1bd (patch) | |
tree | e09cadd3008a7baa1180c1668994f79b5b1fab03 | |
parent | c4a1c2ff425127ba05a2c3d60cba3b03c19284cd (diff) |
escape characters in git user name
-rw-r--r-- | app/helpers/projects_helper.rb | 2 | ||||
-rw-r--r-- | changelogs/unreleased/18308-escape-characters.yml | 5 | ||||
-rw-r--r-- | spec/helpers/projects_helper_spec.rb | 11 |
3 files changed, 17 insertions, 1 deletions
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 0c8cb9ba235..ddeff490d3a 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -320,7 +320,7 @@ module ProjectsHelper def git_user_name if current_user - current_user.name + current_user.name.gsub('"', '\"') else _("Your name") end diff --git a/changelogs/unreleased/18308-escape-characters.yml b/changelogs/unreleased/18308-escape-characters.yml new file mode 100644 index 00000000000..8766e971490 --- /dev/null +++ b/changelogs/unreleased/18308-escape-characters.yml @@ -0,0 +1,5 @@ +--- +title: Escape quotes in git username +merge_request: 14020 +author: Brandon Everett +type: fixed diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb index 1437479831e..a76c75e0c08 100644 --- a/spec/helpers/projects_helper_spec.rb +++ b/spec/helpers/projects_helper_spec.rb @@ -469,4 +469,15 @@ describe ProjectsHelper do expect(recorder.count).to eq(1) end end + + describe '#git_user_name' do + let(:user) { double(:user, name: 'John "A" Doe53') } + before do + allow(helper).to receive(:current_user).and_return(user) + end + + it 'parses quotes in name' do + expect(helper.send(:git_user_name)).to eq('John \"A\" Doe53') + end + end end |