diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index e89ecb38760c94677fd60a23d55ea2cd51751434..fbd8be043afa33e5ef66c5ecba6b2520cd71f69e 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -33,7 +33,7 @@ class PeopleController < ApplicationController format.html do #only do it if it is an email address if params[:q].try(:match, Devise.email_regexp) - people = Person.where(:diaspora_handle => params[:q]) + people = Person.where(:diaspora_handle => params[:q].downcase) webfinger(params[:q]) if people.empty? else people = Person.search(params[:q], current_user) diff --git a/lib/webfinger.rb b/lib/webfinger.rb index 2b742afa461ce9673d8a849f82d14832277ea08e..d22f7aba05512ffa0629cf7b294e5b4de18c0f64 100644 --- a/lib/webfinger.rb +++ b/lib/webfinger.rb @@ -4,7 +4,7 @@ require File.join(Rails.root, 'lib/webfinger_profile') class Webfinger class WebfingerFailedError < RuntimeError; end def initialize(account) - @account = account.strip.gsub('acct:','').to_s + @account = account.strip.gsub('acct:','').to_s.downcase @ssl = true Rails.logger.info("event=webfinger status=initialized target=#{account}") end diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index 598b0e63d8f95b4c6027830e57e852ebdf15fa3c..c0525b2e828d6ed0b812b140e3d87efcd2fb6596 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -57,6 +57,14 @@ describe PeopleController do get :index, :q => "eugene@example.org" assigns[:people][0].id.should == eugene2.id end + + it "downcases the handle before trying to find someone by it" do + eugene2 = Factory.create(:person, :diaspora_handle => "eugene@example.org", + :profile => Factory.build(:profile, :first_name => "Eugene", + :last_name => "w", :searchable => false)) + get :index, :q => "Eugene@Example.ORG" + assigns[:people][0].id.should == eugene2.id + end it "does not redirect to person page if there is exactly one match" do get :index, :q => "Korth" diff --git a/spec/lib/webfinger_spec.rb b/spec/lib/webfinger_spec.rb index 25002e5c80b6d303d89c10728e01128f717c5040..305ab361466dd5bbea6fbf401a2516d6c55f7acb 100644 --- a/spec/lib/webfinger_spec.rb +++ b/spec/lib/webfinger_spec.rb @@ -32,6 +32,12 @@ describe Webfinger do n = Webfinger.new("mbs348@gmail.com") n.instance_variable_get(:@account).should_not be nil end + + it 'downcases account' do + account = "BIGBOY@Example.Org" + n = Webfinger.new(account) + n.instance_variable_get(:@account).should == account.downcase + end it 'should set ssl as the default' do foo = Webfinger.new(account)