diff options
author | Go MAEDA <maeda@farend.jp> | 2019-03-03 11:55:15 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2019-03-03 11:55:15 +0000 |
commit | 3ce803e82bc6d35718c6711f19b2260e039cc726 (patch) | |
tree | f86d16f1d8fcfc13ae3507f29d642f1104656a70 | |
parent | 77f35cb81841b4747ee54862c7ad0dc6b69ab1ca (diff) | |
download | redmine-3ce803e82bc6d35718c6711f19b2260e039cc726.tar.gz redmine-3ce803e82bc6d35718c6711f19b2260e039cc726.zip |
Parse author's name enclosed in parentheses in the From field when creating a user account from an email (#17699).
Patch by Go MAEDA.
git-svn-id: http://svn.redmine.org/redmine/trunk@17914 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rwxr-xr-x | app/models/mail_handler.rb | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb index de59d6397..d271d3299 100755 --- a/app/models/mail_handler.rb +++ b/app/models/mail_handler.rb @@ -544,12 +544,9 @@ class MailHandler < ActionMailer::Base # Creates a User for the +email+ sender # Returns the user or nil if it could not be created def create_user_from_email - from = email.header['from'].to_s - addr, name = from, nil - if m = from.match(/^"?(.+?)"?\s+<(.+@.+)>$/) - addr, name = m[2], m[1] - end - if addr.present? + if from_addr = email.header['from'].try(:addrs).to_a.first + addr = from_addr.address + name = from_addr.display_name || from_addr.comments.to_a.first user = self.class.new_user_from_attributes(addr, name) if handler_options[:no_notification] user.mail_notification = 'none' |