mirror of
https://github.com/omniauth/omniauth.git
synced 2022-11-09 12:31:49 -05:00
Uses Hashie 1.2 to prevent pollution of subhashes in InfoHash. Closes #495
This commit is contained in:
parent
bbc8558a38
commit
6d0e5c9cf5
3 changed files with 10 additions and 1 deletions
|
@ -6,6 +6,8 @@ module OmniAuth
|
|||
# is able to provide into the InfoHash (stored as the `'info'`
|
||||
# key).
|
||||
class AuthHash < Hashie::Mash
|
||||
def self.subkey_class; Hashie::Mash end
|
||||
|
||||
# Tells you if this is considered to be a valid
|
||||
# OmniAuth AuthHash. The requirements for that
|
||||
# are that it has a provider name, a uid, and a
|
||||
|
@ -23,6 +25,8 @@ module OmniAuth
|
|||
end
|
||||
|
||||
class InfoHash < Hashie::Mash
|
||||
def self.subkey_class; Hashie::Mash end
|
||||
|
||||
def name
|
||||
return self[:name] if self[:name]
|
||||
return "#{first_name} #{last_name}".strip if first_name? || last_name?
|
||||
|
|
|
@ -8,7 +8,7 @@ Gem::Specification.new do |gem|
|
|||
gem.email = ['michael@intridea.com', 'sferik@gmail.com']
|
||||
|
||||
gem.add_runtime_dependency 'rack'
|
||||
gem.add_runtime_dependency 'hashie'
|
||||
gem.add_runtime_dependency 'hashie', '~> 1.2'
|
||||
|
||||
gem.add_development_dependency 'maruku', '~> 0.6'
|
||||
gem.add_development_dependency 'simplecov', '~> 0.4'
|
||||
|
|
|
@ -91,6 +91,11 @@ describe OmniAuth::AuthHash do
|
|||
subject.info = {:first_name => 'Bob', :last_name => 'Examplar'}
|
||||
hash['info']['name'].should == 'Bob Examplar'
|
||||
end
|
||||
|
||||
it 'should not pollute the URL hash with "name" etc' do
|
||||
subject.info = {'urls' => {'Homepage' => "http://homepage.com"}}
|
||||
subject.to_hash['info']['urls'].should == {'Homepage' => "http://homepage.com"}
|
||||
end
|
||||
end
|
||||
|
||||
describe OmniAuth::AuthHash::InfoHash do
|
||||
|
|
Loading…
Reference in a new issue