forked from mikel/mail
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mail 2.6.6 Security: * mikel#1097 – SMTP security: prevent command injection via To/From addresses. (jeremy) Bugs: * mikel#689 - Fix Exim delivery method broken by mikel#477 in 2.5.4. (jethrogb)
- Loading branch information
Showing
42 changed files
with
306 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
source "https://rubygems.org" | ||
source 'https://rubygems.org' | ||
|
||
gemspec | ||
|
||
gem "tlsmail", "~> 0.0.1" if RUBY_VERSION <= "1.8.6" | ||
gem "jruby-openssl", :platforms => :jruby | ||
gem "rake", "< 11.0", :platforms => :ruby_18 | ||
gem 'tlsmail', '~> 0.0.1' if RUBY_VERSION <= '1.8.6' | ||
gem 'jruby-openssl', :platforms => :jruby | ||
gem 'rake', '< 11.0', :platforms => :ruby_18 | ||
gem 'rdoc', '< 4.3', :platforms => [ :ruby_18, :ruby_19 ] | ||
gem 'mime-types', '< 2.0', :platforms => [ :ruby_18, :ruby_19 ] | ||
|
||
# For gems not required to run tests | ||
group :local_development, :test do | ||
gem "appraisal", "~> 1.0" unless RUBY_VERSION <= "1.8.7" | ||
gem 'appraisal', '~> 1.0' unless RUBY_VERSION < '1.9' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,58 @@ | ||
# frozen_string_literal: true | ||
module Mail | ||
module CheckDeliveryParams | ||
def check_delivery_params(mail) | ||
if Utilities.blank?(mail.smtp_envelope_from) | ||
raise ArgumentError.new('An SMTP From address is required to send a message. Set the message smtp_envelope_from, return_path, sender, or from address.') | ||
module CheckDeliveryParams #:nodoc: | ||
class << self | ||
def check(mail) | ||
[ check_from(mail.smtp_envelope_from), | ||
check_to(mail.smtp_envelope_to), | ||
check_message(mail) ] | ||
end | ||
|
||
if Utilities.blank?(mail.smtp_envelope_to) | ||
raise ArgumentError.new('An SMTP To address is required to send a message. Set the message smtp_envelope_to, to, cc, or bcc address.') | ||
def check_from(addr) | ||
if Utilities.blank?(addr) | ||
raise ArgumentError, "SMTP From address may not be blank: #{addr.inspect}" | ||
end | ||
|
||
check_addr 'From', addr | ||
end | ||
|
||
def check_to(addrs) | ||
if Utilities.blank?(addrs) | ||
raise ArgumentError, "SMTP To address may not be blank: #{addrs.inspect}" | ||
end | ||
|
||
Array(addrs).map do |addr| | ||
check_addr 'To', addr | ||
end | ||
end | ||
|
||
message = mail.encoded if mail.respond_to?(:encoded) | ||
if Utilities.blank?(message) | ||
raise ArgumentError.new('An encoded message is required to send an email') | ||
def check_addr(addr_name, addr) | ||
validate_smtp_addr addr do |error_message| | ||
raise ArgumentError, "SMTP #{addr_name} address #{error_message}: #{addr.inspect}" | ||
end | ||
end | ||
|
||
[mail.smtp_envelope_from, mail.smtp_envelope_to, message] | ||
def validate_smtp_addr(addr) | ||
if addr.bytesize > 2048 | ||
yield 'may not exceed 2kB' | ||
end | ||
|
||
if /[\r\n]/ =~ addr | ||
yield 'may not contain CR or LF line breaks' | ||
end | ||
|
||
addr | ||
end | ||
|
||
def check_message(message) | ||
message = message.encoded if message.respond_to?(:encoded) | ||
|
||
if Utilities.blank?(message) | ||
raise ArgumentError, 'An encoded message is required to send an email' | ||
end | ||
|
||
message | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.