diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-23 12:36:30 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-23 12:36:30 +0000 |
commit | 1fd639393f171099a091b2f13fe9271ea8390d6c (patch) | |
tree | 3e431c7a677513125c6b31cfa2f0ed8531901ddb /lib/net/protocol.rb | |
parent | 8ab27ebbb14be80e844ebeada7197458440c6ab5 (diff) | |
download | ruby-1fd639393f171099a091b2f13fe9271ea8390d6c.tar.gz |
net/protocol.rb: fix SMTP dot stuffing
* net/protocol.rb (using_each_crlf_line): fix SMTP dot-stuffing
for messages not ending with a new-line.
[ruby-core:61441] [Bug #9627] [fix GH-616]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/net/protocol.rb')
-rw-r--r-- | lib/net/protocol.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb index 14a68e1115..25477014fb 100644 --- a/lib/net/protocol.rb +++ b/lib/net/protocol.rb @@ -267,7 +267,7 @@ module Net # :nodoc: def write_message_0(src) prev = @written_bytes each_crlf_line(src) do |line| - write0 line.sub(/\A\./, '..') + write0 dot_stuff(line) end @written_bytes - prev end @@ -308,11 +308,15 @@ module Net # :nodoc: private + def dot_stuff(s) + s.sub(/\A\./, '..') + end + def using_each_crlf_line @wbuf = '' yield if not @wbuf.empty? # unterminated last line - write0 @wbuf.chomp + "\r\n" + write0 dot_stuff(@wbuf.chomp) + "\r\n" elsif @written_bytes == 0 # empty src write0 "\r\n" end |