Skip to content
This repository has been archived by the owner on Mar 3, 2021. It is now read-only.

Support file paths with spaces for RETR command #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/fake_ftp/server_commands/retr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
module FakeFtp
module ServerCommands
class Retr
def run(ctx, filename = '', *)
def run(ctx, *filename_parts)
filename = filename_parts.join(' ')
ctx.respond_with('501 No filename given') if filename.empty?

f = ctx.file(filename.to_s)
Expand Down
12 changes: 12 additions & 0 deletions spec/functional/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,18 @@
.to eql("226 File transferred\r\n")
end

it 'accepts RETR with a filepath containing spaces' do
server.add_file(file_prefix + 'some dir/some file', '1234567890')
client.write("RETR #{file_prefix}some dir/some file\r\n")
expect(SpecHelper.gets_with_timeout(client))
.to eql("150 File status ok, about to open data connection\r\n")
data = SpecHelper.gets_with_timeout(data_client, endwith: "\0")
data_client.close
expect(data).to eql('1234567890')
expect(SpecHelper.gets_with_timeout(client))
.to eql("226 File transferred\r\n")
end

it 'accepts DELE with a filename' do
server.add_file('some_file', '1234567890')
client.write("DELE some_file\r\n")
Expand Down