1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
shugo 2016-07-05 22:14:18 +00:00
parent b0087b178e
commit 34a0e098f7
3 changed files with 18 additions and 0 deletions

View file

@ -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.

View file

@ -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

View file

@ -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)