Commit dc576fb0 authored by Steffen van Bergerem's avatar Steffen van Bergerem Committed by Jonne Haß

Check if person is nil in person_image_tag

closes #6286
parent f1d6e944
......@@ -14,6 +14,7 @@
* Fix mobile photos index page [#6243](https://github.com/diaspora/diaspora/pull/6243)
* Fix conversations view with no contacts [#6266](https://github.com/diaspora/diaspora/pull/6266)
* Links in the left sidebar are now clickable on full width [#6267](https://github.com/diaspora/diaspora/pull/6267)
* Guard against passing nil into person\_image\_tag [#6286](https://github.com/diaspora/diaspora/pull/6286)
## Features
......
......@@ -32,6 +32,7 @@ module PeopleHelper
end
def person_image_tag(person, size = :thumb_small)
return "" if person.nil? || person.profile.nil?
image_tag(person.profile.image_url(size), :alt => person.name, :class => 'avatar', :title => person.name, 'data-person_id' => person.id)
end
......
......@@ -117,6 +117,24 @@ describe NotificationsController, :type => :controller do
expect(assigns[:notifications].count).to eq(1)
end
end
context "after deleting a person" do
before do
user = FactoryGirl.create(:user_with_aspect)
user.share_with(alice.person, user.aspects.first)
user.person.delete
end
it "succeeds" do
get :index
expect(response).to be_success
end
it "succeeds on mobile" do
get :index, format: :mobile
expect(response).to be_success
end
end
end
describe "#read_all" do
......
......@@ -23,6 +23,9 @@ describe PeopleHelper, :type => :helper do
end
describe "#person_image_tag" do
it "returns an empty string if person is nil" do
expect(person_image_tag(nil)).to eq("")
end
it "should not allow basic XSS/HTML" do
@person.profile.first_name = "I'm <h1>Evil"
@person.profile.last_name = "I'm <h1>Evil"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment