Skip to content

Commit

Permalink
Better fix for 81e9940, sending to addresses with a leading hyphen, w…
Browse files Browse the repository at this point in the history
…hich confuses the sendmail command line into thinking the addresses are config options. Using '--' as an options terminator is supported by every sendmail implementation I found.
  • Loading branch information
jeremy committed Jan 28, 2013
1 parent 81e9940 commit a944f31
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion lib/mail/network/delivery_methods/sendmail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def deliver!(mail)
envelope_from = mail.return_path || mail.sender || mail.from_addrs.first
return_path = "-f #{self.class.shellquote(envelope_from)}" if envelope_from

arguments = [settings[:arguments], return_path].compact.join(" ")
arguments = [settings[:arguments], return_path, '--'].compact.join(" ")

quoted_destinations = mail.destinations.collect { |d| self.class.shellquote(d) }
self.class.call(settings[:location], arguments, quoted_destinations.join(' '), mail)
Expand Down
16 changes: 8 additions & 8 deletions spec/mail/network/delivery_methods/exim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
end

Mail::Exim.should_receive(:call).with('/usr/sbin/exim',
'-i -t -f "roger@test.lindsaar.net"',
'-i -t -f "roger@test.lindsaar.net" --',
'"marcel@test.lindsaar.net" "bob@test.lindsaar.net"',
mail)
mail.deliver!
Expand All @@ -52,7 +52,7 @@
end

Mail::Exim.should_receive(:call).with('/usr/sbin/exim',
'-i -t -f "return@test.lindsaar.net"',
'-i -t -f "return@test.lindsaar.net" --',
'"to@test.lindsaar.net"',
mail)

Expand All @@ -75,7 +75,7 @@
end

Mail::Exim.should_receive(:call).with('/usr/sbin/exim',
'-i -t -f "sender@test.lindsaar.net"',
'-i -t -f "sender@test.lindsaar.net" --',
'"to@test.lindsaar.net"',
mail)

Expand All @@ -96,7 +96,7 @@
end

Mail::Exim.should_receive(:call).with('/usr/sbin/exim',
'-i -t -f "from@test.lindsaar.net"',
'-i -t -f "from@test.lindsaar.net" --',
'"to@test.lindsaar.net"',
mail)
mail.deliver
Expand All @@ -116,7 +116,7 @@
end

Mail::Exim.should_receive(:call).with('/usr/sbin/exim',
'-i -t -f "\"from+suffix test\"@test.lindsaar.net"',
'-i -t -f "\"from+suffix test\"@test.lindsaar.net" --',
'"to@test.lindsaar.net"',
mail)
mail.deliver
Expand All @@ -133,7 +133,7 @@
end

Mail::Exim.should_receive(:call).with('/usr/sbin/exim',
'-i -t -f "from@test.lindsaar.net"',
'-i -t -f "from@test.lindsaar.net" --',
'"-hyphen@test.lindsaar.net"',
mail)
mail.deliver
Expand All @@ -152,7 +152,7 @@
end

Mail::Exim.should_receive(:call).with('/usr/sbin/exim',
'-f "from@test.lindsaar.net"',
'-f "from@test.lindsaar.net" --',
'"marcel@test.lindsaar.net" "bob@test.lindsaar.net"',
mail)
mail.deliver!
Expand All @@ -170,7 +170,7 @@
end

Mail::Exim.should_receive(:call).with('/usr/sbin/exim',
"-f \"\\\"foo\\\\\\\"\\;touch /tmp/PWNED\\;\\\\\\\"\\\"@blah.com\"",
"-f \"\\\"foo\\\\\\\"\\;touch /tmp/PWNED\\;\\\\\\\"\\\"@blah.com\" --",
'"marcel@test.lindsaar.net"',
mail)
mail.deliver!
Expand Down
18 changes: 9 additions & 9 deletions spec/mail/network/delivery_methods/sendmail_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
end

Mail::Sendmail.should_receive(:call).with('/usr/sbin/sendmail',
'-i -t -f "roger@test.lindsaar.net"',
'-i -t -f "roger@test.lindsaar.net" --',
'"marcel@test.lindsaar.net" "bob@test.lindsaar.net"',
mail)
mail.deliver!
Expand All @@ -45,7 +45,7 @@
subject 'invalid RFC2822'
end

Mail::Sendmail.should_receive(:popen).with('/usr/sbin/sendmail -i -t -f "roger@test.lindsaar.net" "marcel@test.lindsaar.net" "bob@test.lindsaar.net"')
Mail::Sendmail.should_receive(:popen).with('/usr/sbin/sendmail -i -t -f "roger@test.lindsaar.net" -- "marcel@test.lindsaar.net" "bob@test.lindsaar.net"')

mail.deliver!
end
Expand All @@ -68,7 +68,7 @@
end

Mail::Sendmail.should_receive(:call).with('/usr/sbin/sendmail',
'-i -t -f "return@test.lindsaar.net"',
'-i -t -f "return@test.lindsaar.net" --',
'"to@test.lindsaar.net"',
mail)

Expand All @@ -91,7 +91,7 @@
end

Mail::Sendmail.should_receive(:call).with('/usr/sbin/sendmail',
'-i -t -f "sender@test.lindsaar.net"',
'-i -t -f "sender@test.lindsaar.net" --',
'"to@test.lindsaar.net"',
mail)

Expand All @@ -112,7 +112,7 @@
end

Mail::Sendmail.should_receive(:call).with('/usr/sbin/sendmail',
'-i -t -f "from@test.lindsaar.net"',
'-i -t -f "from@test.lindsaar.net" --',
'"to@test.lindsaar.net"',
mail)
mail.deliver
Expand All @@ -132,7 +132,7 @@
end

Mail::Sendmail.should_receive(:call).with('/usr/sbin/sendmail',
'-i -t -f "\"from+suffix test\"@test.lindsaar.net"',
'-i -t -f "\"from+suffix test\"@test.lindsaar.net" --',
'"to@test.lindsaar.net"',
mail)
mail.deliver
Expand All @@ -149,7 +149,7 @@
end

Mail::Sendmail.should_receive(:call).with('/usr/sbin/sendmail',
'-i -t -f "from@test.lindsaar.net"',
'-i -t -f "from@test.lindsaar.net" --',
'"-hyphen@test.lindsaar.net"',
mail)
mail.deliver
Expand All @@ -168,7 +168,7 @@
end

Mail::Sendmail.should_receive(:call).with('/usr/sbin/sendmail',
'-f "from@test.lindsaar.net"',
'-f "from@test.lindsaar.net" --',
'"marcel@test.lindsaar.net" "bob@test.lindsaar.net"',
mail)
mail.deliver!
Expand All @@ -186,7 +186,7 @@
end

Mail::Sendmail.should_receive(:call).with('/usr/sbin/sendmail',
"-f \"\\\"foo\\\\\\\"\\;touch /tmp/PWNED\\;\\\\\\\"\\\"@blah.com\"",
"-f \"\\\"foo\\\\\\\"\\;touch /tmp/PWNED\\;\\\\\\\"\\\"@blah.com\" --",
%("\\\"foo\\\\\\\"\\;touch /tmp/PWNED\\;\\\\\\\"\\\"@blah.com"),
mail)
mail.deliver!
Expand Down

0 comments on commit a944f31

Please sign in to comment.