diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-07-05 22:14:18 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-07-05 22:14:18 +0000 |
commit | 34a0e098f7b5cf4fbceb5e9ef254557787a27fff (patch) | |
tree | 566b104ef15f60520331826fd5312234a676dbfe | |
parent | b0087b178e9a588c7afef9025447892710ce4a0d (diff) |
* lib/net/ftp.rb (putline): raise an ArgumentError when
CR or LF is included in a line.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | lib/net/ftp.rb | 3 | ||||
-rw-r--r-- | test/net/ftp/test_ftp.rb | 10 |
3 files changed, 18 insertions, 0 deletions
@@ -1,3 +1,8 @@ +Wed Jul 6 07:11:27 2016 Shugo Maeda <shugo@ruby-lang.org> + + * lib/net/ftp.rb (putline): raise an ArgumentError when + CR or LF is included in a line. + Tue Jul 5 20:49:30 2016 SHIBATA Hiroshi <hsbt@ruby-lang.org> * ext/json/*, test/json/*: Update json-2.0.1. diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb index cfd8cf7945..bd89956d36 100644 --- a/lib/net/ftp.rb +++ b/lib/net/ftp.rb @@ -295,6 +295,9 @@ module Net if @debug_mode print "put: ", sanitize(line), "\n" end + if /[\r\n]/ =~ line + raise ArgumentError, "A line must not contain CR or LF" + end line = line + CRLF @sock.write(line) end diff --git a/test/net/ftp/test_ftp.rb b/test/net/ftp/test_ftp.rb index 4759772cb1..ca71a918e0 100644 --- a/test/net/ftp/test_ftp.rb +++ b/test/net/ftp/test_ftp.rb @@ -1633,6 +1633,16 @@ EOF end end + def test_putline_reject_crlf + ftp = Net::FTP.new + assert_raise(ArgumentError) do + ftp.send(:putline, "\r") + end + assert_raise(ArgumentError) do + ftp.send(:putline, "\n") + end + end + private def create_ftp_server(sleep_time = nil) |