escape characters in git user name

This commit is contained in:
Brandon Everett 2017-09-13 12:39:50 +00:00 committed by Rémy Coutable
parent c4a1c2ff42
commit 528f90b4e5
3 changed files with 17 additions and 1 deletions

View file

@ -320,7 +320,7 @@ module ProjectsHelper
def git_user_name
if current_user
current_user.name
current_user.name.gsub('"', '\"')
else
_("Your name")
end

View file

@ -0,0 +1,5 @@
---
title: Escape quotes in git username
merge_request: 14020
author: Brandon Everett
type: fixed

View file

@ -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