diff options
-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 |