Skip to content

Instantly share code, notes, and snippets.

@kawaguchi
Forked from dakatsuka/mail_patch.rb
Created March 27, 2012 02:33
Show Gist options
  • Save kawaguchi/2211954 to your computer and use it in GitHub Desktop.
Save kawaguchi/2211954 to your computer and use it in GitHub Desktop.
ドットが連続したメールアドレスに対処するパッチ(Mail::Message.from)
# coding: utf-8
module Mail
class Message
def from_with_patch_rfc_violation
str = from_without_patch_rfc_violation
begin
str = str.join
rescue
str = str.to_s
end
str.scan(/^.*?([a-zA-Z0-9._\/+-]+@[a-zA-Z0-9._-]+?)(?![a-zA-Z0-9._-]).*$/).flatten.first
end
alias_method_chain :from, :patch_rfc_violation
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment