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

merge revision(s) r46457,r46458: [Backport #9949]

* lib/net/ftp.rb (gets, readline): read lines without LF properly.
	  [ruby-core:63205] [Bug #9949]

	* test/net/ftp/test_buffered_socket.rb: related test.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagachika 2014-06-29 18:08:43 +00:00
parent dfba910f74
commit bdab29b10a
4 changed files with 55 additions and 5 deletions

View file

@ -1,3 +1,10 @@
Mon Jun 30 03:07:22 2014 Shugo Maeda <shugo@ruby-lang.org>
* lib/net/ftp.rb (gets, readline): read lines without LF properly.
[ruby-core:63205] [Bug #9949]
* test/net/ftp/test_buffered_socket.rb: related test.
Mon Jun 30 02:59:08 2014 Shugo Maeda <shugo@ruby-lang.org>
* lib/net/imap.rb (body_type_1part): Gmail IMAP reports a body

View file

@ -1105,13 +1105,16 @@ module Net
end
def gets
return readuntil("\n")
rescue EOFError
return nil
line = readuntil("\n", true)
return line.empty? ? nil : line
end
def readline
return readuntil("\n")
line = gets
if line.nil?
raise EOFError, "end of file reached"
end
return line
end
end
# :startdoc:

View file

@ -0,0 +1,40 @@
require "net/ftp"
require "test/unit"
require "ostruct"
require "stringio"
class FTPTest < Test::Unit::TestCase
def test_gets_empty
sock = create_buffered_socket("")
assert_equal(nil, sock.gets)
end
def test_gets_one_line
sock = create_buffered_socket("foo\n")
assert_equal("foo\n", sock.gets)
end
def test_gets_one_line_without_term
sock = create_buffered_socket("foo")
assert_equal("foo", sock.gets)
end
def test_gets_two_lines
sock = create_buffered_socket("foo\nbar\n")
assert_equal("foo\n", sock.gets)
assert_equal("bar\n", sock.gets)
end
def test_gets_two_lines_without_term
sock = create_buffered_socket("foo\nbar")
assert_equal("foo\n", sock.gets)
assert_equal("bar", sock.gets)
end
private
def create_buffered_socket(s)
io = StringIO.new(s)
return Net::FTP::BufferedSocket.new(io)
end
end

View file

@ -1,6 +1,6 @@
#define RUBY_VERSION "2.1.2"
#define RUBY_RELEASE_DATE "2014-06-30"
#define RUBY_PATCHLEVEL 155
#define RUBY_PATCHLEVEL 156
#define RUBY_RELEASE_YEAR 2014
#define RUBY_RELEASE_MONTH 6