From: Eric Davis Date: Sat, 19 Jun 2010 19:24:17 +0000 (+0000) Subject: Accept email from anonymous users with an empty from address. #5604 X-Git-Tag: 1.0.0~54 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d48eb2de47c3b75e567b849b0be93b041f18279b;p=redmine.git Accept email from anonymous users with an empty from address. #5604 Contributed by Andrew Fenn git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3783 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb index ae204b4f7..2b57e1ab4 100644 --- a/app/models/mail_handler.rb +++ b/app/models/mail_handler.rb @@ -49,7 +49,7 @@ class MailHandler < ActionMailer::Base logger.info "MailHandler: ignoring email from Redmine emission address [#{sender_email}]" if logger && logger.info return false end - @user = User.find_by_mail(sender_email) + @user = User.find_by_mail(sender_email) if sender_email.present? if @user && !@user.active? logger.info "MailHandler: ignoring email from non-active user [#{@user.login}]" if logger && logger.info return false diff --git a/test/fixtures/mail_handler/ticket_by_empty_user.eml b/test/fixtures/mail_handler/ticket_by_empty_user.eml new file mode 100644 index 000000000..e0d168a7d --- /dev/null +++ b/test/fixtures/mail_handler/ticket_by_empty_user.eml @@ -0,0 +1,17 @@ +Return-Path: +Received: from osiris ([127.0.0.1]) + by OSIRIS + with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200 +Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris> +To: +Subject: Ticket by unknown user +Date: Sun, 22 Jun 2008 12:28:07 +0200 +MIME-Version: 1.0 +Content-Type: text/plain; + format=flowed; + charset="iso-8859-1"; + reply-type=original +Content-Transfer-Encoding: 7bit + +This is a ticket submitted by an unknown user. + diff --git a/test/unit/mail_handler_test.rb b/test/unit/mail_handler_test.rb index 29659daae..467084f1b 100644 --- a/test/unit/mail_handler_test.rb +++ b/test/unit/mail_handler_test.rb @@ -169,6 +169,15 @@ class MailHandlerTest < ActiveSupport::TestCase assert issue.author.anonymous? end end + + def test_add_issue_by_anonymous_user_with_no_from_address + Role.anonymous.add_permission!(:add_issues) + assert_no_difference 'User.count' do + issue = submit_email('ticket_by_empty_user.eml', :issue => {:project => 'ecookbook'}, :unknown_user => 'accept') + assert issue.is_a?(Issue) + assert issue.author.anonymous? + end + end def test_add_issue_by_anonymous_user_on_private_project Role.anonymous.add_permission!(:add_issues)