diff options
-rw-r--r-- | lib/gitlab/auth/o_auth/auth_hash.rb | 3 | ||||
-rw-r--r-- | lib/gitlab/utils.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/auth/o_auth/auth_hash_spec.rb | 7 |
3 files changed, 8 insertions, 4 deletions
diff --git a/lib/gitlab/auth/o_auth/auth_hash.rb b/lib/gitlab/auth/o_auth/auth_hash.rb index 72a187377d0..91b9ddc0d00 100644 --- a/lib/gitlab/auth/o_auth/auth_hash.rb +++ b/lib/gitlab/auth/o_auth/auth_hash.rb @@ -60,8 +60,7 @@ module Gitlab def get_info(key) value = info[key] - Gitlab::Utils.force_utf8(value) if value - value + value.is_a?(String) ? Gitlab::Utils.force_utf8(value) : value end def username_and_email diff --git a/lib/gitlab/utils.rb b/lib/gitlab/utils.rb index 31c9e18c996..c66ce0434a4 100644 --- a/lib/gitlab/utils.rb +++ b/lib/gitlab/utils.rb @@ -22,7 +22,7 @@ module Gitlab end def force_utf8(str) - str.force_encoding(Encoding::UTF_8) + str.dup.force_encoding(Encoding::UTF_8) end def ensure_utf8_size(str, bytes:) diff --git a/spec/lib/gitlab/auth/o_auth/auth_hash_spec.rb b/spec/lib/gitlab/auth/o_auth/auth_hash_spec.rb index 40001cea22e..a5436149818 100644 --- a/spec/lib/gitlab/auth/o_auth/auth_hash_spec.rb +++ b/spec/lib/gitlab/auth/o_auth/auth_hash_spec.rb @@ -40,7 +40,11 @@ describe Gitlab::Auth::OAuth::AuthHash do last_name: last_name_ascii, name: name_ascii, nickname: nickname_ascii, - uid: uid_ascii + uid: uid_ascii, + address: { + locality: 'some locality', + country: 'some country' + } } end @@ -51,6 +55,7 @@ describe Gitlab::Auth::OAuth::AuthHash do it { expect(auth_hash.username).to eql nickname_utf8 } it { expect(auth_hash.name).to eql name_utf8 } it { expect(auth_hash.password).not_to be_empty } + it { expect(auth_hash.location).to eq 'some locality, some country' } end context 'email not provided' do |